Web Analytics Made Easy -
StatCounter Removing $_POST - CodingForum

Announcement

Collapse
No announcement yet.

Removing $_POST

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Removing $_POST

    Lots of people on my forum have been complaining because when you post a message, the click back or refresh the page it posts it again or gives an error.

    What would be the best method (in theory) for me to create a system that prevents posting twice, and that message "Are you sure you wish to re-send information"?

  • #2
    you can send them to a site with two links :

    view new post

    back to forum

    Comment


    • #3
      I had such problem when I was coding the online shop. When user click add goods to cart button the browser could stuck or may be because of slow internet the user will click it once again or even worse will press F5 button to reload the page. So the last POST request will be sent again and he will get the same goods twice in his cart

      Here is how I solved that problem. After user presses the button I am sending data to some addtocart.php script which do all operations and after it outputs simple blank page with META code to make redirect to necessary page within 5 second and of cause if JS is disabled there is HTML link with the text 'If you browser will not redirect you within 5 sec click here'.

      So if user will press F5 he will just refreshes the last page (without POST request), if he will press back button he will be moved back to that white page which will redirects him forward again

      Comment


      • #4
        Originally posted by PHP6 View Post
        I had such problem when I was coding the online shop. When user click add goods to cart button the browser could stuck or may be because of slow internet the user will click it once again or even worse will press F5 button to reload the page. So the last POST request will be sent again and he will get the same goods twice in his cart

        Here is how I solved that problem. After user presses the button I am sending data to some addtocart.php script which do all operations and after it outputs simple blank page with META code to make redirect to necessary page within 5 second and of cause if JS is disabled there is HTML link with the text 'If you browser will not redirect you within 5 sec click here'.

        So if user will press F5 he will just refreshes the last page (without POST request), if he will press back button he will be moved back to that white page which will redirects him forward again
        So that's how forums like these work, when you login it comes up with a page saying: Welcome Ludatha you are now logged in, please wait...

        Comment


        • #5
          Originally posted by Ludatha View Post
          So that's how forums like these work, when you login it comes up with a page saying: Welcome Ludatha you are now logged in, please wait...
          Almost the same but the key is to output as little HTML page as possible, that will save you from the situation when the page could stuck in the middle and user will press F5 button. Or even better solution is (I have used in other project) not to output anything except header(‘location: http://example.com’). In that case user do not need to press anything and there is no requirement that JS will be enabled on the client side. All known browsers will proceed redirect in a header.

          Comment

          Working...
          X