Preventing POST Again When User Clicks Back Button

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bruce

    Preventing POST Again When User Clicks Back Button

    I have a number of forms that do significant work based on variables
    POSTed from the form. What is the common method of detecting and
    preventing this work from being done when the form is POSTed as the
    result of the user clicking the Back or Reload buttons in the browser?

    --Bruce
  • kingofkolt

    #2
    Re: Preventing POST Again When User Clicks Back Button

    "Bruce" <bvanderw-news5021@mailbl ocks.com> wrote in message
    news:3thkj0lvms 3m8152en2s3pf6g uerlvlia7@4ax.c om...[color=blue]
    > I have a number of forms that do significant work based on variables
    > POSTed from the form. What is the common method of detecting and
    > preventing this work from being done when the form is POSTed as the
    > result of the user clicking the Back or Reload buttons in the browser?
    >
    > --Bruce[/color]

    You could give it a form action of, say, "formhandler.ph p". On
    formhandler.php , handle the information from the form (naturally), then send
    the user via header("Locatio n: ...") to "success.ph p", which displays some
    message like "The data was successfully submitted." The back button will
    then send them to the original form, and the refresh button will just
    refresh the success message. Either way, the form won't be re-POSTed.

    If the data from the form needs to be immediately displayed, then save the
    data from formhandler.php into $_SESSION variables and send a location
    header to your display page.

    - JP


    Comment

    • Bruce

      #3
      Re: Preventing POST Again When User Clicks Back Button

      I guess the problem occurs when I need to display the same page again,
      like when I delete a line item in a list of items, or click on a link
      to send a stock e-mail to someone.

      --Bruce

      On Sat, 04 Sep 2004 23:45:32 GMT, "kingofkolt "
      <jessepNOSPAM@c omcast.net> wrote:
      [color=blue]
      >"Bruce" <bvanderw-news5021@mailbl ocks.com> wrote in message
      >news:3thkj0lvm s3m8152en2s3pf6 guerlvlia7@4ax. com...[color=green]
      >> I have a number of forms that do significant work based on variables
      >> POSTed from the form. What is the common method of detecting and
      >> preventing this work from being done when the form is POSTed as the
      >> result of the user clicking the Back or Reload buttons in the browser?
      >>
      >> --Bruce[/color]
      >
      >You could give it a form action of, say, "formhandler.ph p". On
      >formhandler.ph p, handle the information from the form (naturally), then send
      >the user via header("Locatio n: ...") to "success.ph p", which displays some
      >message like "The data was successfully submitted." The back button will
      >then send them to the original form, and the refresh button will just
      >refresh the success message. Either way, the form won't be re-POSTed.
      >
      >If the data from the form needs to be immediately displayed, then save the
      >data from formhandler.php into $_SESSION variables and send a location
      >header to your display page.
      >
      >- JP
      >[/color]

      Comment

      • kingofkolt

        #4
        Re: Preventing POST Again When User Clicks Back Button

        "Bruce" <bvanderw-news5021@mailbl ocks.com> wrote in message
        news:0flkj0trhu aggh7g3lompe3nh qthb04i44@4ax.c om...[color=blue]
        > I guess the problem occurs when I need to display the same page again,
        > like when I delete a line item in a list of items, or click on a link
        > to send a stock e-mail to someone.
        >
        > --Bruce
        >
        > On Sat, 04 Sep 2004 23:45:32 GMT, "kingofkolt "
        > <jessepNOSPAM@c omcast.net> wrote:
        >[color=green]
        > >"Bruce" <bvanderw-news5021@mailbl ocks.com> wrote in message
        > >news:3thkj0lvm s3m8152en2s3pf6 guerlvlia7@4ax. com...[color=darkred]
        > >> I have a number of forms that do significant work based on variables
        > >> POSTed from the form. What is the common method of detecting and
        > >> preventing this work from being done when the form is POSTed as the
        > >> result of the user clicking the Back or Reload buttons in the browser?
        > >>
        > >> --Bruce[/color]
        > >
        > >You could give it a form action of, say, "formhandler.ph p". On
        > >formhandler.ph p, handle the information from the form (naturally), then[/color][/color]
        send[color=blue][color=green]
        > >the user via header("Locatio n: ...") to "success.ph p", which displays[/color][/color]
        some[color=blue][color=green]
        > >message like "The data was successfully submitted." The back button will
        > >then send them to the original form, and the refresh button will just
        > >refresh the success message. Either way, the form won't be re-POSTed.
        > >
        > >If the data from the form needs to be immediately displayed, then save[/color][/color]
        the[color=blue][color=green]
        > >data from formhandler.php into $_SESSION variables and send a location
        > >header to your display page.
        > >
        > >- JP
        > >[/color]
        >[/color]

        In that case (if I understand your problem), you can still use the same form
        action ("formhandler.p hp"), and from there, header() the user back to the
        original page s/he was viewing. The page will then be updated with the new
        (or deleted) records.

        - JP


        Comment

        • kingofkolt

          #5
          Re: Preventing POST Again When User Clicks Back Button

          "Bruce" <bvanderw-news5021@mailbl ocks.com> wrote in message
          news:0flkj0trhu aggh7g3lompe3nh qthb04i44@4ax.c om...[color=blue]
          > I guess the problem occurs when I need to display the same page again,
          > like when I delete a line item in a list of items, or click on a link
          > to send a stock e-mail to someone.
          >
          > --Bruce
          >
          > On Sat, 04 Sep 2004 23:45:32 GMT, "kingofkolt "
          > <jessepNOSPAM@c omcast.net> wrote:
          >[color=green]
          > >"Bruce" <bvanderw-news5021@mailbl ocks.com> wrote in message
          > >news:3thkj0lvm s3m8152en2s3pf6 guerlvlia7@4ax. com...[color=darkred]
          > >> I have a number of forms that do significant work based on variables
          > >> POSTed from the form. What is the common method of detecting and
          > >> preventing this work from being done when the form is POSTed as the
          > >> result of the user clicking the Back or Reload buttons in the browser?
          > >>
          > >> --Bruce[/color]
          > >
          > >You could give it a form action of, say, "formhandler.ph p". On
          > >formhandler.ph p, handle the information from the form (naturally), then[/color][/color]
          send[color=blue][color=green]
          > >the user via header("Locatio n: ...") to "success.ph p", which displays[/color][/color]
          some[color=blue][color=green]
          > >message like "The data was successfully submitted." The back button will
          > >then send them to the original form, and the refresh button will just
          > >refresh the success message. Either way, the form won't be re-POSTed.
          > >
          > >If the data from the form needs to be immediately displayed, then save[/color][/color]
          the[color=blue][color=green]
          > >data from formhandler.php into $_SESSION variables and send a location
          > >header to your display page.
          > >
          > >- JP
          > >[/color]
          >[/color]

          In that case (if I understand your problem), you can still use the same form
          action ("formhandler.p hp"), and from there, header() the user back to the
          original page s/he was viewing. The page will then be updated with the new
          (or deleted) records.

          - JP


          Comment

          • Manuel Lemos

            #6
            Re: Preventing POST Again When User Clicks Back Button

            Hello,

            On 09/04/2004 08:27 PM, Bruce wrote:[color=blue]
            > I have a number of forms that do significant work based on variables
            > POSTed from the form. What is the common method of detecting and
            > preventing this work from being done when the form is POSTed as the
            > result of the user clicking the Back or Reload buttons in the browser?[/color]

            You may want to try this class that lets you specify a message that
            appears on alert box when the users tries to submit the same form again.
            It does not stop an user from submitting the same form again if he
            really wants, but it prevents that many nervous users submit the same
            form again by accident, which in my experience happens quite often:




            --

            Regards,
            Manuel Lemos

            PHP Classes - Free ready to use OOP components written in PHP
            Free PHP Classes and Objects 2025 Versions with PHP Example Scripts, PHP Tutorials, Download PHP Scripts, PHP articles, Remote PHP Jobs, Hire PHP Developers, PHP Book Reviews, PHP Language OOP Materials


            PHP Reviews - Reviews of PHP books and other products


            Metastorage - Data object relational mapping layer generator

            Comment

            Working...