xProteuSx Posted December 21, 2007 Share Posted December 21, 2007 How do I go about writing an 'if' statement that runs if the page was reloaded? What I have is a multiple choice test. Page1.php gives you a question and multiple choices. Page2.php marks your result. If you gave the correct answer on page1.php your user score is incremented by one via a script on page2.php. However, if you get the question right, you can keep on refreshing page2.php, and your score is incremented every time you refresh. I want to avoid this. Any ideas? Link to comment https://forums.phpfreaks.com/topic/82648-if-page-reloaded/ Share on other sites More sharing options...
chigley Posted December 21, 2007 Share Posted December 21, 2007 Sessions maybe? Link to comment https://forums.phpfreaks.com/topic/82648-if-page-reloaded/#findComment-420342 Share on other sites More sharing options...
jitesh Posted December 21, 2007 Share Posted December 21, 2007 You can use Session. Example : At begins : $_SESSION['pages'] = array(); (1) page 1 $_SESSION['pages'][1] = "ANSWER_IS_GIVEN"; (2) $_SESSION['pages'][2] = "ANSWER_IS_GIVEN"; When you go back from page 2 to page 1 check: if(isset($_SESSION['pages'][1])){ echo "Answer is already submited with this page."; } Link to comment https://forums.phpfreaks.com/topic/82648-if-page-reloaded/#findComment-420345 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.