By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,949 Members | 1,824 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,949 IT Pros & Developers. It's quick & easy.

preventing browser back-tracking and cache control

P: n/a
I did a quiz, where at the end, the user certifies. It was brought to my
attention that after certification, the user could just hit the back
button and submit another certification (for example, maybe a co-worker)
without going through the quiz.

There is no login involved. Is there a way, or, what is the best way to
prevent the user from going back?

I've tried:

header("Cache-Control: no-cache");
header("Cache-Control: no-store");
Feb 7 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"Acerola" <dh**@yahooo.comwrote in message
news:dh************************@news.us.easynews.c om...
I did a quiz, where at the end, the user certifies. It was brought to my
attention that after certification, the user could just hit the back
button and submit another certification (for example, maybe a co-worker)
without going through the quiz.

There is no login involved. Is there a way, or, what is the best way to
prevent the user from going back?

I've tried:

header("Cache-Control: no-cache");
header("Cache-Control: no-store");
If you create a session, and an array entry such as $_SESSION['resubmit'] in
conjunction with a hidden input in your form you can detect cached
resubmissions.
I.e.;
if( ! isset($_SESSION['resubmit']))
{
$_SESSION['resubmit'] = $sub = 1;//make them equal;
}
if($_SESSION['resubmit']==$_REQUEST['resub'] or exit('Got yah'))
{
do stuff here
}
<form etc>
<input type="hidden" name="resub" value="<?php echo ++$sub ?>">
</form>
You can modify this slightly to allow further entries via same form without
allowing a refresh to add extraneous data.
HTH
Vince
Feb 8 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.