SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast ethe's Avatar
    Join Date
    Oct 2005
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation A form with different steps

    Hi there

    i'm busy with a form that exist out of different steps. I made a controller for a this see below. The problem is when I go from step 1 to step 2 i put the post vars in a session. In step 2 the session works fine en displays the post vars from step 1, but when i submit form 2 the session is destroyed and i'll loose the post vars from step 1 and 2

    PHP Code:
    <?php include_once $_SERVER['DOCUMENT_ROOT']."/php/library/functions-includer.php";

    //print_r($_POST);

    if(isset($_POST['formStap'])){
        
    $formStap $_POST['formStap'];
    }
    else{
        
    $formStap NULL;
    }

    switch (
    $formStap) {   
        case 
    "1":        
            include_once 
    $_SERVER['DOCUMENT_ROOT']."/php/proces/form/reserveren/proces_stap1.php";
                        
            if(
    $nextStap == "2"){
                
    session_start();
            
                global 
    $arrayStap1;
                
    $arrayStap1 = array();
                
                
    $x 0;
                foreach(
    $_POST as $array[$x]){
                    
    $x++;
                }
                
                for(
    $i 0$i <sizeof($array); $i++){
                    
    //$arrayStap1[$i] = $array[$i];
                    
    $_SESSION[$i] = $array[$i];
                }
                
    print_r($_SESSION);        
                include_once 
    $_SERVER['DOCUMENT_ROOT']."/pages/reserveren/stap2/index.php";
            }    
            else{
                include_once 
    $_SERVER['DOCUMENT_ROOT']."/pages/reserveren/stap1/index.php";
            }    
        break;                
            
        case 
    "2":    
            
    session_start();
            include_once 
    $_SERVER['DOCUMENT_ROOT']."/php/proces/form/reserveren/proces_stap2.php";
                        
            if(
    $nextStap == "3"){
                
    session_start();
            
                global 
    $arrayStap2;
                
    $arrayStap2 = array();
                
                
    $x 0;
                foreach(
    $_POST as $array[$x]){
                    
    $x++;
                }
                
                for(
    $i 0$i <sizeof($array); $i++){
                    
    //$arrayStap2[$i] = $array[$i];
                    
    $_SESSION[19+$i] = $array[$i];
                }
                
    print_r($_SESSION);
                
                include_once 
    $_SERVER['DOCUMENT_ROOT']."/pages/reserveren/stap3/index.php";
            }    
            else{
                
    print_r($_SESSION);
                include_once 
    $_SERVER['DOCUMENT_ROOT']."/pages/reserveren/stap2/index.php";
            }
        break;            
                            
        case 
    "3":    
            include_once 
    $_SERVER['DOCUMENT_ROOT']."/php/proces/form/reserveren/proces_stap3.php";
                        
            if(
    $nextStap == "4"){
            
                global 
    $arrayStap3;
                
    $arrayStap3 = array();
                
                
    $x 0;
                foreach(
    $_POST as $array[$x]){
                    
    $x++;
                }
                
                for(
    $i 0$i <sizeof($array); $i++){
                    
    $arrayStap3[$i] = $array[$i];
                }
                
    /*
                print_r($arrayStap1);
                echo "<br>";
                print_r($arrayStap2);
                echo "<br>";
                print_r($arrayStap3);
                echo "<br>";
                print_r($_POST);
                */
                
                
    include_once $_SERVER['DOCUMENT_ROOT']."/pages/reserveren/stap4/index.php";
            }    
            else{
                include_once 
    $_SERVER['DOCUMENT_ROOT']."/pages/reserveren/stap3/index.php";
            }
        break;
                            
        case 
    "4":    
        break;
            
        default:  include_once 
    $_SERVER['DOCUMENT_ROOT']."/pages/reserveren/stap1/index.php";
    }

    ?>

  2. #2
    SitePoint Enthusiast ethe's Avatar
    Join Date
    Oct 2005
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    steps in form

    Has no one have a clue? about this problem?

  3. #3
    SitePoint Addict GeertDD's Avatar
    Join Date
    Feb 2005
    Location
    Belgium
    Posts
    334
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I had a quick look. Did you forget session_start() in case 3?


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
  •