View Full Version : PHP form
dean5000v
May 9th 2008, 3:53 am
ok ive done a simple form which posts to
<?php echo $_SERVER['PHP_SELF'];?>">
ok when the page gets refreshed after the submit button has been pressed it then resends the data again, how can i stop it from resending the data once the page is resent ??
Amilo
May 9th 2008, 4:20 am
Have a look here (http://apptools.com/phptools/forms/forms1.php) and see if it helps you.
dean5000v
May 9th 2008, 5:08 am
ermm didnt see anything in there that wld help, i just wnt it so if the page is refreshed the data doesnt get resent.
blueparukia
May 9th 2008, 5:35 am
So the data is from the form? In the form, add a hidden input:
<input type="hidden" name="dataResend" />
For PHP
<?
if{!ISSET($_POST['dataResend'])){
//Add code here for when the page is refreshed
}
else{
//Add Code here for when the form is sent.
//Refresh the page, clearing all data:
header("Location: ".$_SERVER['PHP_SELF']."");
}
?>
tamilsoft
May 9th 2008, 5:45 am
Check with this code:
<?php
if(isset($_POST['resend']) && $_POST['resend'] == $_COOKIE['resendvalue'])
{
echo 'do insert';
setcookie('resendvalue','',time()-1000,'/');
}
$resendval = time();
setcookie('resendvalue',$resendval,time()+1000,'/');
?>
<form method="post">
<input type="text" name="mytest">
<input type="submit" value="ok">
<input type="hidden" name="resend" value="<?php echo $resendval;?>">
</form>
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.