Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Apr 2005
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts

    What is the best way to retain information

    Hi,

    What is the best way in php to retain a main.php form's input value on the input textbox after it has been redirected back from a sqlInsert.php for SQL proccessing?

    This is what I get for using Session to retain the information after page redirecting.
    Error:
    <br />
    <b>Notice</b>: Undefined index: script in <b>c:\inetpub\wwwroot\cyyamHub\internalweb\moviescript.php</b> on line <b>64</b><br />

    This is what I did:
    main.php
    Code:
    <textarea name="script" cols="100" rows="12" id="script"><?php echo $_SESSION['script']; /*This Session is to retain the data*/?>
    </textarea>
    Submit value to sqlInsert.php using submit button then redirect the page back to main.php
    PHP Code:
    $gopublic "";
    $script $_POST['script'];
    $errorMsg "";

            if(
    $script == "")
                
    $errorMsg $errorMsg "+Please Fill in Something";
                        
            if(
    $errorMsg == "")
            {
                
    $con dbConnection();
                
    mysql_select_db("cyyamhub"$con);
                
                
    $sql="INSERT INTO moviescript (script)";
                
    $sql=$sql " VALUES ";
                
    $sql=$sql "('" $script "')";
                
                if (!
    mysql_query($sql,$con))
                  {
                    die(
    'Error: ' mysql_error());
                  }
                
    mysql_close($con);
                                
                
    $_SESSION['script'] = $script;    
                
    $_SESSION['err'] = "Your script have been submitted";
                
    header('Location: ../internalweb/main.php');
            }
            else
            {
                
    $_SESSION['script'] = $script;
                
    $_SESSION['err']=$errorMsg;
                
    header('Location: ../internalweb/main.php');
            } 

  • #2
    Regular Coder musher's Avatar
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    are you Initialize sessions?
    PHP Code:
    session_start(); 
    is the error line (64) the first code post?
    Last edited by musher; 09-01-2006 at 05:04 AM.
    Thanks
    Jim M

    "Lord, help me to become the person my dog thinks I am" - Dawn Ewing
    "If you must know. Yes, I do enjoy running after the dog sled when I fall off" - Me

    www.huskyzone.com -- Woodland Siberians

  • #3
    New Coder
    Join Date
    Apr 2005
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes I do have the function session_start().

    The strange thing is, the error doesn't occurs in Firefox, it occurs when I use IE.

  • #4
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    IE has many errors that dont occur in firefox,
    help spread firefox
    http://www.spreadfirefox.com/

  • #5
    Regular Coder musher's Avatar
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by ooiyh
    Yes I do have the function session_start().

    The strange thing is, the error doesn't occurs in Firefox, it occurs when I use IE.
    sessions disabled in IE ????
    Thanks
    Jim M

    "Lord, help me to become the person my dog thinks I am" - Dawn Ewing
    "If you must know. Yes, I do enjoy running after the dog sled when I fall off" - Me

    www.huskyzone.com -- Woodland Siberians


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •