SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    PHP warrior dkode's Avatar
    Join Date
    Sep 2001
    Location
    Planet Namek
    Posts
    329
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    breaking survey into seperate parts?

    I have a very long survey form with 4 different sections. Is there anyway with php to split this form into 4 popup windows so the person can click on the section they wish to fill out and when they are done, go back to the host survey form and continue on? I know there must be a way to do it, i'm just at a loss as to how i would pass the variables off? Cookies perhaps?
    "Mankind cannot define memory, yet it defines mankind"
    -- Project 2501, Ghost in the Shell

    Smarty | PEAR | PHP Manual | MySQL Manual

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sessions, Sessions, Sessions. Store the survey results in session variables and then you can keep track of them through the whole session.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    PHP warrior dkode's Avatar
    Join Date
    Sep 2001
    Location
    Planet Namek
    Posts
    329
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is there some sort of global variable to access all session variables that are registered. I want to loop through them to format before i send an email.
    "Mankind cannot define memory, yet it defines mankind"
    -- Project 2501, Ghost in the Shell

    Smarty | PEAR | PHP Manual | MySQL Manual

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well if you were tyo register a session variable named let's say $SESSION.

    You could store the results for each survey as another array under $SESSION something like.


    PHP Code:
    $SESSION['survey1'][] = $response

    So you basically would have something like this at the end.

    Code:
    $SESSION['survey1'][0]
    $SESSION['survey1'][1]
    $SESSION['survey1'][2]
    $SESSION['survey1'][3]
    $SESSION['survey2'][0]
    $SESSION['survey2'][1]
    $SESSION['survey2'][2]
    $SESSION['survey2'][3]
    $SESSION['survey3'][0]
    $SESSION['survey3'][1]
    $SESSION['survey3'][2]
    $SESSION['survey3'][3]
    $SESSION['survey4'][0]
    $SESSION['survey4'][1]
    $SESSION['survey4'][2]
    $SESSION['survey4'][3]
    Then looping through tem would be as simple as this for example.


    PHP Code:
    $SESSION['survey1'][0] = '1.0';
    $SESSION['survey1'][1] = '1.1';
    $SESSION['survey1'][2] = '1.2';
    $SESSION['survey1'][3] = '1.3';
    $SESSION['survey2'][0] = '2.0';
    $SESSION['survey2'][1] = '2.1';
    $SESSION['survey2'][2] = '2.2';
    $SESSION['survey2'][3] = '2.3';
    $SESSION['survey3'][0] = '3.0';
    $SESSION['survey3'][1] = '3.1';
    $SESSION['survey3'][2] = '3.2';
    $SESSION['survey3'][3] = '3.3';
    $SESSION['survey4'][0] = '4.0';
    $SESSION['survey4'][1] = '4.1';
    $SESSION['survey4'][2] = '4.2';
    $SESSION['survey4'][3] = '4.3';






    foreach(
    $SESSION as $key => $val) {
        if(
    is_array($val)) {
            print 
    "<b>$key</b><br>";
            foreach(
    $SESSION[$key] as $key2 => $val2) {
                print 
    "&nbsp;&nbsp;$val2<br>";
                }
            }
        else {
            print 
    "$val<br>";
            }
        } 
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    PHP warrior dkode's Avatar
    Join Date
    Sep 2001
    Location
    Planet Namek
    Posts
    329
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is that a multi-dimensional array?
    "Mankind cannot define memory, yet it defines mankind"
    -- Project 2501, Ghost in the Shell

    Smarty | PEAR | PHP Manual | MySQL Manual

  6. #6
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, 'tis. I want to use those more often, just so I can say I've used a matrix before...my oh my, it sounds so cool.

  7. #7
    PHP warrior dkode's Avatar
    Join Date
    Sep 2001
    Location
    Planet Namek
    Posts
    329
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok i have another question now...

    Now in this "popup window" where they fill out survey1, i have two if blocks, one for !$submit to show the form and another for $submit if the form has been filled out.. this second part then sets all of the $SESSIONS[][] variables and then i want it to close the window...i tried doing the following:

    Code:
    if ($submit) {
    // Register these variables in session
    $SESSION['survey1'][] = $var1;
    $SESSION['survey1'][] = $var2;
    
    // Close this window
    ?>
    <script language=javascript type=text/javascript>\n"; 
    	window.close();
    </script>
    <?
    }
    ?>
    All this does is refresh the window and then when i try to complete the entire form my main php script tells me that i supplied an invalid statement where i have: foreach($SESSION as $key => $val) {

    I guess this means $SESSION was never set?
    "Mankind cannot define memory, yet it defines mankind"
    -- Project 2501, Ghost in the Shell

    Smarty | PEAR | PHP Manual | MySQL Manual

  8. #8
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you call session_start() before setting session vars? Did you register SESSION as session var in your main page. Using
    PHP Code:
    session_register("SESSION"); 
    In your body tag stick your window.close
    Code:
    <body onLoad="self.close();">
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  9. #9
    PHP warrior dkode's Avatar
    Join Date
    Sep 2001
    Location
    Planet Namek
    Posts
    329
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i do session_start() and session_register('SESSION');

    in my main window (not the popup)

    do i need to do session_register in each window?
    i have session_start in each window.

    also...now that i put that body onLoad in there, when i click submit in the popup the first time and it refreshes, i click it again and then it closes?
    Last edited by dkode; Oct 9, 2001 at 10:56.
    "Mankind cannot define memory, yet it defines mankind"
    -- Project 2501, Ghost in the Shell

    Smarty | PEAR | PHP Manual | MySQL Manual


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
  •