faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

26 of 54 people (48%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

How do I stop a previous url?mode=del&cust=name being repeated when the user hits their back button?

Feb 17th, 2008 23:59
dman, Chris Thompson, Kaan Turel, Alex Dean, Chris Kings-Lynne, Alan Lord, http://www.ttnr.org


You should be using POST instead of GET for important operations that 
should only be performed once.
Even with POST, someone can hit 'BACK' and repeat the operation, though
the browser will say something like 'The document contains POST data, do
you wish to resubmit.'.
Kaan : use sessions...
Chris : or better yet.  submit the form to action="<?=
$_SERVER['PHP_SELF']; ?>
then insert php code in that page to do stuff with the form info
submitted.......example:
formpage.php
<code>
<?
if($_POST) {
    //  do stuff with the form info
    //  now that we are done with form
    //  redirect to second page
    header("Location: page2.php");
}
?>
<html>
<body>
<form action="<?= $_SERVER['PHP_SELF']; ?>">
</form>
</body>
</html>
</code>
This stops the problem of people double posting and stops them from
seeing the info that is submitted via the url.