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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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