Jump to content
Larry Ullman's Book Forums

Data Is Resubmitted After Page Refresh


Recommended Posts

i think i found the problem. this problem occur because i use the same page to submit a form  by using this code

  } elseif ($values === 'POST') {

so when i do refresh the page it will resubmit the form. i read some book and found that to prevent this to happen is by using HTTP redirect. but i wonder is it any other effective way to prevent this beside using HTTP redirect.

Link to post
Share on other sites

As far as I know, this is the intended behavior and most sites implement things this way.

Granted, you could do a redirect, but that will make your code more complex and it seems like you're fighting intended and well-known behavior at that point.

 

If you click on the URL bar and hit enter, it'll reload the page without posting the form.

What I can't understand is if you're concerned about this for testing purposes or if you are concerned about your end users.

In other words, what's the problem?

Link to post
Share on other sites

I'm just afraid if my client which have a slow connection or have connection is interrupted they will refresh the pages. it will cause the data will be resubmitted. I can't say to them to click on URL and hit enter. I know that jQuery will solve this, but what is the trick for PHP if I only use PHP.

Link to post
Share on other sites

I've seen a lot of sites that put disclaimers near the submit button that say something like the following:

"After clicking Submit, please wait a few moments and please do not click the Back button or close your browser."

 

Beyond that, what can you do?

At this point in the history of the Internet though, I think that people with slow connections have learned not to hit the Back button, etc. when the submit a form.

And if they do hit Refresh or the Back button, what are you going to do if it's PHP only?

There really is nothing.

 

I guess my point is, you can only prevent idiots from hurting themselves to a certain point.

Beyond that, it's not your concern.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...