Jump to content

Need help with simple script


$Three3

Recommended Posts

Hi, I have a small problem with a site I am creating. I have made an online school site for a client that allows a student to take their test online and once they are done taking the "Math" test for example, it will show them the numbers they have missed and the numbers they have correctly answered. My concern is that if they click the back button, the test is still available and the radio buttons are still selected from the first time they took the test. Is there anyway for me to give them an error when they try to access the page again? Something like, "This page has expired". Thanks a lot in advance for the help.

Link to comment
https://forums.phpfreaks.com/topic/192764-need-help-with-simple-script/
Share on other sites

you could use a session to hold a test key then on completion increment the key so that when they go back to the test page the keys wont match up and you can respond accordingly

 

That sounds like something I can definitely try. I currently have it setup like this:

 

//Validate that the user is not accessing this page in error or coming back from completion page
$r = $_SERVER['HTTP_REFERER'] ;
if ($r != 'http://sitename.com/Tests/Tests.php') {
header('Location: http://sitename.com/Home/Home.html') ;
exit() ;
}

 

This code is at the beginning of my script and it validates that the user is coming from the correct page. But this code does not seem to run when the user clicks the back button. So would a session solve this or would it cause the same problem? Thanks a lot for the help.

 

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.