473,770 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2345

"Acerola" <dh**@yahooo.co mwrote in message
news:dh******** *************** *@news.us.easyn ews.com...
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
4617
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 the result of the user clicking the Back or Reload buttons in the browser? --Bruce
3
6008
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 verify the existance of the data, so as to prevent the multiple insertion. Is there any other way to prevent it otherthan introducing another field for this purpose and verifying its existance? Regards,
8
2340
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 various techniques in the past (depending on circumstances) but I'd be interested in the techniques you guys currently use. Thanks --
8
2465
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 was the entire function failing, but I tested with alerts and found that it was only the 'window.open' that fails to execute. The function is being called by a link, and I suspected some problem with the body alink/vlink but after cutting that out...
1
1046
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, the exception is caught by the thick client in C# as expected. The exception text gets displayed in a message box. All this works just fine. However, the problem I am having is that if IIS throws its own excecption that has nothing to do with my...
4
4204
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 been wiped and anything that posts back or refreshes the page will send them back to the login screen... but it would be nice if either the navigation history is wiped, or some setting is set that causes all the previous content to be expired. Is...
6
4445
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 its state... Kev
10
3740
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 again, which created duplicate records. So I am trying to disable the button as soon as it is clicked, and as soon as it's done, re-enable it again.
2
3439
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 page, then save action will call) this should not be happen. only data will save , when we click on the save button. Why every refresh save action getting call and what is solution on this problem? Is there any javascript method available to...
2
2094
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){ document.write( "<h1>Hello There</h1>" ); } else if(window.history.back(-1) == window.location){
0
9595
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8891
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3974
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3578
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2822
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.