refreshing
Moderator: General Moderators
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
refreshing
is there any way i could make it so when someone refreshes on a page where the submitted a form, that it does not submit again?
i saw a similar post, but it had to do with the back button
i saw a similar post, but it had to do with the back button
- EvilWalrus
- Site Admin
- Posts: 209
- Joined: Thu Apr 18, 2002 3:21 pm
- Location: Springmont, PA USA
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
- NetDragonX
- Forum Newbie
- Posts: 15
- Joined: Sat May 25, 2002 3:00 pm
- Location: Southern California
Well I basicly figure I do it quite a bit simpler than most of that.
Just write a check before the script bit enters the data in the file.
Say $include is the new data as it will be written in the file and $last is the last line added to the file before. Thus after the data has been entered and someone then does a refresh... they should be exactly the same.
So simply do a:
if ($include != $last){
go and write it in
}
and voila...
That's how I have it running in a little GB I wrote and it works perfect.
Just write a check before the script bit enters the data in the file.
Say $include is the new data as it will be written in the file and $last is the last line added to the file before. Thus after the data has been entered and someone then does a refresh... they should be exactly the same.
So simply do a:
if ($include != $last){
go and write it in
}
and voila...
That's how I have it running in a little GB I wrote and it works perfect.
A cookie would definately stop the data being entered into a DB or whatnot twice. But unfortunately I can't think of anyway to stop the browser from re-submitting the form data, Javascript might have some sort of object that prevents it, but I've never encountered it before...
Hmm....that's a bit of a pain; it won't let me use && in my conditional statement, just prints & instead...
Code: Select all
<?php
// HTML Form data.
if ($submit AND !isset($Form_Sent)) {
setcookie("Form_Sent", $User, time() +3600 * 24 * 365 * 10,"/");
// Process Form data.
// Inform user that data has been successfully been processed.
}
else {
// Inform user that data has already been sent.
exit;
}
?>There is:
Code: Select all
<?php
session_start();
if(!session_is_registered("didpoll"))
$didpoll="false";
$connect = mysql_connect("localhost:3306", "esites") && mysql_select_db("polls")
or $failed = "Could not connect to database.";
if($despoll && $didpoll!="true")
{
$didpoll="true";
mysql_query("insert into layout set rating="$despoll"");
} else { $pollerror = "ERROR: You can only vote once!"; }
?>