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 9 of 9
  1. #1
    CPD
    CPD is offline
    New Coder
    Join Date
    Jul 2012
    Location
    Ontario Canada
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Loosing $_Session and $_GET data in the middle of a form

    Hello all

    I have a script that sends $_GET data via url that I need to keep, but I loose it when going through a 6 level dependent drop down.
    PHP Code:
    <?
    session_start
    ();
    // store session data
    $_SESSION['client_id']= $_GET['id'];
    ?>
    This $_GET['id'] comes from the previous page via url, but I loose it during an auto submit, all the $_GET variables unset and I need to keep them for further processing
    even trying to store it in the $_SESSION['client_id'] as seen above, gets unset
    PHP Code:
    <?
        
    if($region != null && $lastname != null && $firstname != null && $phone != null && $cust != null)
        {   
    ?>
        <select name="vid" onChange="autoSubmit();">        
            <option value="null">Select Venue</option> 
    <?
            
           
            
            $sql1 
    "SELECT vid, vname FROM venue WHERE re_id = $region";
            
    $venues mysql_query($sql1,$conn);
      
            while(
    $row mysql_fetch_array($venues))

            {      
            echo (
    "<option value=\"{$row['vid']}\" " . ($vid == $row['vid'] || $_GET ["vnm0"] == $row['vname']? " selected" "") . ">{$row['vname']}</option>");    
            }    
    ?>   
        </select>
    <?
        
    }                
    ?>
    How can I store Variables that will stay set until I call an unset on them regardless of how many submits or auto submits the script uses
    Thanks
    Last edited by CPD; 07-28-2012 at 12:17 AM.

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,535
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Well, a GET is part of a page URL, so if you submit a form and it moves to another page, you'll lose the GET unless you put it back into the URL. That' being said, you're storing it into a session already... why not just call the session?

  • #3
    CPD
    CPD is offline
    New Coder
    Join Date
    Jul 2012
    Location
    Ontario Canada
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I do try to recall the session but everything returns NULL

    after an auto submit I get this



    [_SESSION] => Array
    (
    [client_id] => <------this I need and it disappears after an auto submit
    )
    Last edited by CPD; 07-26-2012 at 10:48 PM.

  • #4
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,301
    Thanks
    57
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    Did you remember to call session_start() again in your next script?

    session_start() doesn't just start a session, it also resumes the session and must be used in every php file that uses the session.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • Users who have thanked tangoforce for this post:

    CPD (07-27-2012)

  • #5
    CPD
    CPD is offline
    New Coder
    Join Date
    Jul 2012
    Location
    Ontario Canada
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks so much "tangoforce", the SESSION was not called and therefore SESSION was not transferred to next page, once again THANKS

  • #6
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,301
    Thanks
    57
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    Glad to be of service
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #7
    CPD
    CPD is offline
    New Coder
    Join Date
    Jul 2012
    Location
    Ontario Canada
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts
    How do I declare this thread solved ??

  • #8
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,301
    Thanks
    57
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    Edit your original post at the top and select resolved by the subject.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #9
    CPD
    CPD is offline
    New Coder
    Join Date
    Jul 2012
    Location
    Ontario Canada
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks


  •  

    Posting Permissions

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