|
Posted by Jerry Stuckle on 07/18/06 02:50
Juliette wrote:
> s a n j a y wrote:
>
>> mindwarp wrote:
>>
>>> Hi,
>>>
>>> When a user submits / posts data my php script Inserts data into my
>>> database.
>>> If they refresh the script or click back and click submit again I get
>>> duplicate record.
>>>
>>> Is there an easy solution to this?
>>>
>>> Or do I need to create a hidden field which contains some sort of
>>> unquie data, like a time stamp and have a have a unique field which
>>> stops it adding the record?
>>>
>>> Best regards,
>>>
>>> Jules.
>>>
>>
>> I would go with what Jerry said. Set a session variable indicating
>> that insertion has been done. If user tries to repost, check for
>> existence of the variable and just escape all the insertion code.
>
>
>
> I wouldn't advice that as that would also exclude a user from posting
> *something else* using the same form.
Why? When the form is first displayed, clear the session variable.
Then when the form is submitted, set the variable.
Pretty standard programming.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|