Re: Form trouble

From: Date: Tue, 26 Nov 2002 07:02:56 +0000
Subject: Re: Form trouble
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-126053@lists.php.net to get a copy of this message
Hi, * David H wrote: > After I submited a query, if I use back then forward > again the form will resubmit itself. Which I do not > want. Does anyone have a solution for this problem? Register a token in a session var after submitting the form. When the user get's again on the resubmitted page you should test if the token exists in the session. If it does, you know he has resubmitted the form. <?php if (isset($_POST["submit"])) { if (!isset($_SESSION["token"])) { $_SESSION["token"] = "submitted"; /** * continue validating, parsing etc. * the data */ } else { /** * error: form was resubmitted */ } } else { /** * display form */ ?> <form action="<?php print $PHP_SELF; ?>" method="POST"> . . . </form> <?php } . . . ?> -- PHP Magazines for Professionals PHP Magazin * PHP Magazine http://www.phpmag.de/ * http://www.php-mag.net/ German Edition * International Edition with own topics

« previous php.general (#126053) next »