Re: New to PHP form attributes
| From: | Marek Kilimajer | Date: | Tue, 07 Oct 2003 12:57:17 +0000 |
| Subject: | Re: New to PHP form attributes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-165294@lists.php.net to get a copy of this message | ||
You should use post method for forms that change state on the server, that way the user gets a warning. And you should redirect after processing the form to another page.
if($_GET['action']=='submit') {
INSERT INTO table VALUES (NULL, '$_GET[input]'
header('Location: ...');
} else {
<form action="<? PHP_SELF ?>?action=submit" method="POST">
<input type="text" name="input">
</form>
}
Matthew Oatham wrote:
Hi, I am new to PHP and am more used to JSP. My question is - if I submit a form to a php3 page using action=="<? PHP_SELF ?>" for some processing all is well I can see that form data. After the processing the page is redisplayed - but the data originally sent persits (in the request) this can be a pain if the user was to hit the refresh button then the data is submitted to the server again and if for example the php page does an insert into a database then a new row would be created etc... Is this normal behaviour of php and jsp ? I am not sure but I am noticing it now with php ? Should I be clearing the data from the request somehow after I have done my processing? Thanks Matt _________________________________________________________________ It's fast, it's easy and it's free. Get MSN Messenger today! http://www.msn.co.uk/messenger