Jump to content

If page reloaded ...


xProteuSx

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.