Here's the scenario:
The user enters some data in a form, submits the data, the server stores it in the database and displays an aknowledgement.
Here's the problem:
If the user, on the aknowledgement page, refreshes the page, the data is re-sent and put once more in the database.
How can i prevent this? Is there a way to disable refreshing?
Disable refresh
Moderator: General Moderators
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
An example of another method follows
This will clear the POST/GET variables from the history. OK you will have the $_GET Done left. 
Code: Select all
<?php
if (isset($_GET['done'])) {
echo('Data saved correctly');
} else {
if (count($_POST)>0) {
// Check values and save
// if saved $saved = 1;
}
if ($saved) {
header('Location:page_name.php?done=1');
exit;
} else {
// display_errors
}
?>- Bill H
- DevNet Resident
- Posts: 1136
- Joined: Sat Jun 01, 2002 10:16 am
- Location: San Diego CA
- Contact:
I have this quite often due to popups that refresh the parent window.
I use for the input form: form.php:
And for action.php:
Then they can hit refresh all, they want.
I use for the input form: form.php:
Code: Select all
<form method=post action=doit.php>
<input type-text name=whatever>
</form>Code: Select all
<?php
//code to insert into database, then
header("Location:form.php");
exit;
?>