I am working on an online survey.
Each time I clicked the “Next Question” button, I tried the following:
if(isset($_POST['submit']) && isset($_POST['ans']))
{
$_SESSION['qnum'] = $_SESSION['qnum']+1;
}
Whenever I press the F5 button, the session is updated and a new question is called up.
The session should only increase when you click the button for the next question, otherwise it should not increase.
Below is what I tried after linking to an article:
$pageWasRefreshed = isset($_SERVER['HTTP_CACHE_CONTROL']) && $_SERVER['HTTP_CACHE_CONTROL'] === 'max-age=0';
if($pageWasRefreshed)
{
}
else
{
}
- This approach worked fine in Mozilla Firefox
- In IE, both button presses and F5 are deleted as not updated
- In Chrome, both buttons and F5 are accepted as updated
I tried other options from other articles on StackOverflow and Google, but they did not work at all , including the ajax based solution .