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 ??
ermm didnt see anything in there that wld help, i just wnt it so if the page is refreshed the data doesnt get resent.
So the data is from the form? In the form, add a hidden input: <input type="hidden" name="dataResend" /> Code (markup): 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'].""); } ?> PHP:
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,'/'); ?> PHP: <form method="post"> <input type="text" name="mytest"> <input type="submit" value="ok"> <input type="hidden" name="resend" value="<?php echo $resendval;?>"> </form> HTML: