473,387 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

preventing browser back-tracking and cache control

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
1 2311

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Bruce | last post by:
I have a number of forms that do significant work based on variables POSTed from the form. What is the common method of detecting and preventing this work from being done when the form is POSTed as...
3
by: Raju V.K | last post by:
I am developing a PHP-mysql database. It is noted that when the browser window is refreshed the data is inserted again in the database. unfortunately there is no unique keys that I can use to...
8
by: CJM | last post by:
How do people go about preventing the user from submitting a form for a 2nd time? For example, the user submits a form, clicks on the back button, and the submits the form again. I have used...
8
by: alanstew | last post by:
With the body tag calling out 'window onload', a function with a 'window.open' fails at the 'window.open' line. If I cut out the body tag, the function executes as normal. At first I thought it...
1
by: Jerry J | last post by:
I have an ASP.NET web service that is written in C#. The service is not called using a browser, instead it is called by another thick client C# application. If my web service throws an exception,...
4
by: PJ6 | last post by:
After logging out of my test site I would like to be able to not allow the user to navigate back to previous pages. It's not super-important because if they try to do anything the login state has...
6
by: Kevin Lawrence | last post by:
Hi I need to be able to prevent a Server Button from posting back when clicked, the reason for this is so I can use client-script to disable the button and then when there is a postback to save...
10
by: Oleg Konovalov | last post by:
Hi, I have a Java GUI application where I perform a lot of long DB operations , which takes 5-60 secs to perform. Sometimes user double-clicks the button or just gets impatient and clicks...
2
by: pingalkar | last post by:
In my application, on one form i m getting information from user and save this information , after saving this information again we loading that page. (At this moment if any one try to refresh this...
2
by: Khnumtemu | last post by:
Hello all, I am trying to change a line of text when a user uses the back button to return to a page what I have at the moment is this: <script> if(window.location == window.location){ ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.