fili Posted June 20, 2007 Share Posted June 20, 2007 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 Quote Link to comment Share on other sites More sharing options...
Caesar Posted June 20, 2007 Share Posted June 20, 2007 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.