Jump to content
xisto Community
Sign in to follow this  
alapidus

How Long Do $_post Variables Stay Stored?

Recommended Posts

let's say that for whatever reason, let's say for a survey, i want to make a quiz like w3schools.com has, only with PHP. i would want to put all the questions on different pages, also like w3schools. could each of the submissions stay stored inside PHP's $_POST for 20 pages? if not, how could i get around it?PS. i really don't know anything about ASP other than the fact that w3schools uses it. so please don't explain to me with ASP-specific terms...

Share this post


Link to post
Share on other sites

Take a look at the 'cool' quiz that I created a few days ago. Sub-Zero :: Cool Quiz Do you mean a quiz like that? However, once you leave the results page; when you come back your results are not there anymore! I think this may the thing you are asking about. If you want your results to stay saved, I believe that you should make a database table for the quiz.

 

Then you could use a simple MySQL query to insert the results in the database table. If you make the table, I could give you the query.

 

P.S. http://www.w3schools.com/ is coded in ASP. :-)

Share this post


Link to post
Share on other sites

Take a look at the 'cool' quiz that I created a few days ago.  Sub-Zero :: Cool Quiz Do you mean a quiz like that?  However, once you leave the results page; when you come back your results are not there anymore!  I think this may the thing you are asking about.  If you want your results to stay saved, I believe that you should make a database table for the quiz. 

 

Then you could use a simple MySQL query to insert the results in the database table.  If you make the table, I could give you the query.

 

P.S.  http://www.w3schools.com/ is coded in ASP.  :-)

42224[/snapback]

yeah, but if i were to use a database. i would have to automatically delete the results when they finish the test. then the database storage space and server speed would become inconsistent and too dependent on the quiz page...

Share this post


Link to post
Share on other sites

The best way to store the data is just like lucifer star said, and this is the most widely used, pass the variables over to the next page and store them there with hidden values,eg. of code

<?php//if the previous post variable is $_POST['name'];//then in the next page after the form is submited do this echo"<input type=\"hidden\" name=\"question1\" value=\"".$_POST['name']."\">";?>
or alternatively a database like aproach.
store the answers of every page to a text file in the windows temporary directory ,then after calculating the results just delete the file after wards
and well if you dont delete it windows will, when you reboot the system
or the best alternative and i would recomend this. is use php sessions
every time the form is submited on the next page register the session varible with the value of the form, if you need code for that jus let me know
Edited by stevey (see edit history)

Share this post


Link to post
Share on other sites

let's say that for whatever reason, let's say for a survey, i want to make a quiz like w3schools.com has, only with PHP. i would want to put all the questions on different pages, also like w3schools.

 

could each of the submissions stay stored inside PHP's $_POST for 20 pages? if not, how could i get around it?

 

PS. i really don't know anything about ASP other than the fact that w3schools uses it. so please don't explain to me with ASP-specific terms...

41897[/snapback]


use hidden inputs..

<input type="hidden" name="lastquestion" value="$nameofthelastinput">

Put load of this in all pages, and you will save all them, simple, huh? ;D

by the way, you don't need to use $_POST["varname"], you can simply use $varname only, if register_globals is turned on (in Xisto it is).

Share this post


Link to post
Share on other sites

well its always good to be on the safe side so thats why in my scripts i always use $username = $_POST['username'];its just a habit lol.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.