Re: Duplicate record
| From: | Hallvard | Date: | Mon, 01 Aug 2005 19:56:19 +0000 |
| Subject: | Re: Duplicate record | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-40005@lists.php.net to get a copy of this message | ||
Thanks!
I had already dealt with the problem using unique key, as many others
suggested. However, the records (post your comment-type) doesn't have any
natural key, so I had to concotinate several long text strings, which isn't
nice.
Could you point me in the direction of any code examples for this?
"Alexander Veremyev" <alexander.v@zend.com> wrote in message
news:42EBAFA9.7030409@zend.com...
>
> You could use next simple rules to avoid this problem:
>
> 1. Never change anything in your storage (database) by GET HTTP request
> method.
> 2. Never prepare any Web page by POST method.
> 3. After Form is processed (with a POST method) use HTTP redirect to
> corresponding GET page which should produce a result of processing. (it
> may be the same php script)
>
> So you will have "getters" and "setters" for your Web application.
> Only "getters" will be stored in a browser history in this case and users
> will be able to use back/forward/reload browser functionality without any
> side effects (also without requests to post data again).
>
>
> PS Furthermore, such use of GET and POST methods corresponds to their
> description in HTTP RFC's
>
>
> With best regards,
> Alexander Veremyev.
>
> Hallvard wrote:
>
>> I have a page that posts data from a form to a mysql database.
>>
>> The problem is that if the user hits the reload button on the browser,
>> the data will be posted again, resulting in a duplicate record.
>>
>> How can I avoid that?