The Most Active and Friendliest
Affiliate Marketing Community Online!

“Adavice”/  “1Win

php file value problem

komrad66

New Member
affiliate
Hello all,

I'm a learning php this year but i encounters some problems.

One of them is about php value. The problem is how do i do to prevent a php file from resending the same values into the database whenever the page is refreshed?

Anyone help?


Thanks,

Asep
 
You should redirect users when their post was successful, that way you avoid all such duplicate posts.

Using the post method, posting to a script which will either throw out an error, or redirect the user to the page they where viewing.

Hitting refresh won't repost their message since they where redirected, and hitting the back button will only bring them back to the same page, that is the page they where viewing and posting from.

You can do this redirect using the header function of PHP, it would of cause be a good idea to show a success message on the page you redirect them to, especially if you require some sort of validation of their post, otherwise they might think their post where lost and try to submit it again.
 
Last edited:
To prevent this you could add a captcha image, but it really depends on your website.

A good php programmer would have the script search for existing records before adding a new one.
 
Not necessarily. Usually autoincrements is used on one of the columns in the database, this should avoid exact duplicates.

Extra checking for user errors that almost never occur, is just a waste of coding effort. It would be just as good to add a delete feature which is likely to be required anyway. :botles:
 
banners
Back