Jump to content

Survey Online


fili

Recommended Posts

Hallo there

 

Sorry butt my English is not so good

 

I am pretty new to php and now i need to make an online survey which is going to bee presented  in several pages where in which page are placed some questions. I am trying to store the answer in session until the last page of questions is presented and than to add the question to the mysql db, but it is not working. I can se that the variable of page1 can be printed in page 2 but not on page3 and further.

My question is:

 

How can I do so that I save all the answers to the session variables or something like that so that even if the users is surfing back and forth so the variable are not going to add to the db twice or more.

 

Please help me!

 

Thanks

Link to comment
Share on other sites

Once you define a session variable...it can be used in any page as long as you initiate the session in each page....you can then do whatever you want. keep track of what questions they've already answered....etc...etc.

 

<?php

  sessions_start();

    if(isset($_SESSION['current']) && isset($_GET['q'])) {

       $question = $survey->clean($_GET['q']);

       $query = $db->query("SELECT * FROM sessions WHERE sess_id = '$question'");
       $current = $db->fetch_array($query);

       $answer = $survey->check_question($current[$question]); //Check to see if this question has been answered

    }

?>

 

Keep in mind I just threw that together without much thought so...it is for illustration purposes to give you a basic idea.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.