Results 1 to 2 of 2

Thread: session issue

  1. #1
    Join Date
    Dec 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default session issue

    hey everyone, i am using a session to pass the information from 6 different forms into a validation. the validation occurs after every individual form is processed so the user can't go to the next section unless the previous is accurate. the only problem i am having is that after my form validates and returns to the page when an error is found, the session variables are reset, but when they are correct they remain intact. below is my code, does anyone have any idea how i can get around this....? thanks in advance
    headerImage.php-- Main page where the forms load:
    Code:
     
    <?php
    session_start();	
    header("Cache-control: private");
    foreach($_POST as $key => $var) {
    		$_SESSION[$key] = $var;
    			}	
    ?>
    <?php 
            IF (!isset($_POST['step'])) {
      			include "ListInfo.php";}
    		ELSEIF ($_POST['step'] == 2){
      			include "OptServices.php";}
    		ELSEIF ($_POST['step'] == 3){
    			include "ContInfo.php";}
    
    		ELSEIF ($_POST['step'] == 4){
    			include "BillInfo.php";}
    
    		ELSEIF ($_POST['step'] == 5){
    			include "Survey.php";}
    
    		ELSEIF ($_POST['step'] == 6){
    			include "Terms.php";} 
    			print_r($_SESSION)
    			?>
    ---Part of the validation code--- Only for ListInfo.php
    Code:
    if(empty($SendAddr)){
    $error[] = "";
    	$SendAddr="";
    }
    if(count($error) > 0){
    	header('Location: headerImage.php');
    	echo "<input type='hidden' value='' name='step'>";
    	echo "Please Correct Your Errors Before Proceeding";
    }ELSE{
    	include_once('headerImage.php');
    }
    }

  2. #2
    Join Date
    Feb 2006
    Posts
    236
    Thanks
    8
    Thanked 3 Times in 3 Posts

    Default

    There are several reasons for this type of frustrating failure. Try looking at post by marcosdsanchez, brady and crown2gain on http://us2.php.net/session . The problem lies in the redirect back to the calling page when the data is incomplete. You will have to put some echos in there to see what is incorrect. There are also known issues with IE and sessions.

    Also, make sure that you don't use exit in the script because your session variables will be destroyed.

Bookmarks

Posting Permissions

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