avoid post resubmit on refresh

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

    avoid post resubmit on refresh

    I've a form wich point to itself in order to check if the compulsory values
    are filled. If they are, then I send an email.

    Now, I've seen that if you refresh the form (once the email is sent), then
    the email is sent again. How to clear the POST values ? I won't the form to
    be submitted again. Once the email is sent, then the POST variables should
    be blank.

    Bob


  • Ewoud Dronkert

    #2
    Re: avoid post resubmit on refresh

    On Tue, 14 Jun 2005 10:16:39 +0200, Bob Bedford wrote:[color=blue]
    > I've a form wich point to itself in order to check if the compulsory values
    > are filled. If they are, then I send an email.[/color]

    Post the form to a php-only script with all the logic, from there use
    header() to go back to the form.


    --
    Firefox Web Browser - Rediscover the web - http://getffox.com/
    Thunderbird E-mail and Newsgroups - http://gettbird.com/

    Comment

    • Bob Bedford

      #3
      Re: avoid post resubmit on refresh


      "Ewoud Dronkert" <firstname@last name.net.invali d> a écrit dans le message de
      news: ao7ta19c5svknfb 58a1cv2gu8v4oof 1bm4@4ax.com...[color=blue]
      > On Tue, 14 Jun 2005 10:16:39 +0200, Bob Bedford wrote:[color=green]
      >> I've a form wich point to itself in order to check if the compulsory
      >> values
      >> are filled. If they are, then I send an email.[/color]
      >
      > Post the form to a php-only script with all the logic, from there use
      > header() to go back to the form.
      >
      >[/color]
      I HATE this manner. That means that for every page where there is a form,
      I've to create an other with the logic. It's already quite difficult to get
      a low number of page, but adding every time a new one will kill me (I've
      about 80 php pages on my site).

      Any other way ?


      Comment

      • www.douglassdavis.com

        #4
        Re: avoid post resubmit on refresh


        POST to the same page.

        If the result is unsucsessful, show the errors, and allow them to
        resubmit.

        If the result is successful (page has been processed), use a header to
        redirect to the same page with a GET parameter such as success=true,
        then just display the "Your Email has been sent!" message.

        When it POSTS, it does the processing, when it GETS it displays the
        result.

        Only downside is you can't echo all the info that the user just typed
        in.

        For a really long explanation:
        Java developers discussing Java J2EE, java software, Java programming and other trends in server side development



        ---
        PHP Stuff:


        Comment

        • R. Rajesh Jeba Anbiah

          #5
          Re: avoid post resubmit on refresh

          Bob Bedford wrote:[color=blue]
          > "Ewoud Dronkert" <firstname@last name.net.invali d> a écrit dans le message de
          > news: ao7ta19c5svknfb 58a1cv2gu8v4oof 1bm4@4ax.com...[color=green]
          > > On Tue, 14 Jun 2005 10:16:39 +0200, Bob Bedford wrote:[/color][/color]
          <snip>[color=blue][color=green]
          > > Post the form to a php-only script with all the logic, from there use
          > > header() to go back to the form.
          > >[/color]
          > I HATE this manner. That means that for every page where there is a form,
          > I've to create an other with the logic. It's already quite difficult to get
          > a low number of page, but adding every time a new one will kill me (I've
          > about 80 php pages on my site).
          >
          > Any other way ?[/color]

          if (the page is GETed)
          {
          if (!isset($_SESSI ON['submit_count'][$unique_page_id]))
          $_SESSION['submit_count'][$unique_page_id] = 0;
          //add hidden "submit_cou nt" in form with a value
          $_SESSION['submit_count'][$unique_page_id].
          ini_set('url_re writer.tags', 'form=fakeentry '); //rewrite only the
          form
          output_add_rewr ite_var('submit _count',
          $_SESSION['submit_count'][$unique_page_id]);
          }
          else if (page is POSTed)
          {
          if
          ($_SESSION['submit_count'][$unique_page_id]==$_POST['submit_count'])
          {
          //seems to be ok. Warning: we didn't take care of multiple
          form scenario
          //stuff to DB
          $_SESSION['submit_count'][$unique_page_id] += 1;
          }
          else
          {
          //already processed.
          }
          }

          --
          <?php echo 'Just another PHP saint'; ?>
          Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com

          Comment

          • Bob Bedford

            #6
            Re: avoid post resubmit on refresh


            "www.douglassda vis.com" <douglass_davis @earthlink.net> a écrit dans le
            message de news: 1119018024.0185 92.105860@o13g2 00...legr oups.com...[color=blue]
            >
            > POST to the same page.
            >
            > If the result is unsucsessful, show the errors, and allow them to
            > resubmit.
            >
            > If the result is successful (page has been processed), use a header to
            > redirect to the same page with a GET parameter such as success=true,
            > then just display the "Your Email has been sent!" message.
            >
            > When it POSTS, it does the processing, when it GETS it displays the
            > result.
            >
            > Only downside is you can't echo all the info that the user just typed
            > in.
            >
            > For a really long explanation:
            > http://www.theserverside.com/article...irectAfterPost
            >
            >
            > ---
            > PHP Stuff:
            > http://www.douglassdavis.com
            >
            >[/color]
            Thanks for the tip !

            Cheers.

            Bob


            Comment

            • Bob Bedford

              #7
              Re: avoid post resubmit on refresh


              "R. Rajesh Jeba Anbiah" <ng4rrjanbiah@r ediffmail.com> a écrit dans le
              message de news: 1119166143.7545 89.305780@g47g2 00...legr oups.com...
              Bob Bedford wrote:[color=blue]
              > "Ewoud Dronkert" <firstname@last name.net.invali d> a écrit dans le message
              > de
              > news: ao7ta19c5svknfb 58a1cv2gu8v4oof 1bm4@4ax.com...[color=green]
              > > On Tue, 14 Jun 2005 10:16:39 +0200, Bob Bedford wrote:[/color][/color]
              <snip>[color=blue][color=green]
              > > Post the form to a php-only script with all the logic, from there use
              > > header() to go back to the form.
              > >[/color]
              > I HATE this manner. That means that for every page where there is a form,
              > I've to create an other with the logic. It's already quite difficult to
              > get
              > a low number of page, but adding every time a new one will kill me (I've
              > about 80 php pages on my site).
              >
              > Any other way ?[/color]

              if (the page is GETed)
              {
              if (!isset($_SESSI ON['submit_count'][$unique_page_id]))
              $_SESSION['submit_count'][$unique_page_id] = 0;
              //add hidden "submit_cou nt" in form with a value
              $_SESSION['submit_count'][$unique_page_id].
              ini_set('url_re writer.tags', 'form=fakeentry '); //rewrite only the
              form
              output_add_rewr ite_var('submit _count',
              $_SESSION['submit_count'][$unique_page_id]);
              }
              else if (page is POSTed)
              {
              if
              ($_SESSION['submit_count'][$unique_page_id]==$_POST['submit_count'])
              {
              //seems to be ok. Warning: we didn't take care of multiple
              form scenario
              //stuff to DB
              $_SESSION['submit_count'][$unique_page_id] += 1;
              }
              else
              {
              //already processed.
              }
              }

              --
              <?php echo 'Just another PHP saint'; ?>
              Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com


              Thanks for the tip !

              Cheers.

              Bob


              Comment

              Working...