PHP5/PHP Error Messages
Sorry for the lack of clarity. I am saying that I would like to be able to answer the question once, then a cookie is set for that question. So then, after that cookie has been set, I never need to answer the question until the cookie times out. So in this case, after I answer the question on index.php, a cookie is set, and I am redirected to q1.php. So if I ever go back to index.php, then I am redirected back to q1.php, without having to answer the question again. Hope this is a little clearer. Here is the code again
Thanks for the clarification. This is pretty simple. The first step is to write the cookie when someone has answered the question correctly. This is done with the following line:
setcookie('passed_index', '1' ,time()+60*60*24); //This line sets the cookie for 1 year
The other thing you need to do is to check the existence of the cookie at the top of index.php. If it exists, send the user immediately to q1.php
//Check for the existence of the cookie
That's all there is to it. Of course, in production you would not want to rely on this method, but it does work for your learning scenario.
Full code is available at http://pastebin.com/m6nbXTmF
Please let me know if you have any other questions.