stop someone reloading a page

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

    stop someone reloading a page

    is there a way in either php or html to disable the back and or the
    reload/refresh on a browser so a potential spammer cant just keep refreshing
    the page of a form that sends a confirmation email out

    thanks in advance


  • Jochen Buennagel

    #2
    Re: stop someone reloading a page

    chris wrote:
    [color=blue]
    > is there a way in either php or html to disable the back and or the
    > reload/refresh on a browser so a potential spammer cant just keep refreshing
    > the page of a form that sends a confirmation email out[/color]

    That's a very common problem in web applications. There's different
    solutions:

    - have the "successful ly sent" page redirect to another page (like back
    to where we came from), so the spammer would have to catch a 1-second
    time-window to hit F5.

    - include a uniqid() in a hidden field of the form, so the system won't
    accept more than one form submission with the same ID, e.g. insert the
    ID in a db table when the form is being displayed and remove it again
    when the form is submitted.

    There's prolly lotsa other solutions. These are the one's I've used so
    far. (The first one is less work, the second one is more secure).

    Jochen

    Comment

    • J.O. Aho

      #3
      Re: stop someone reloading a page

      chris wrote:[color=blue]
      > is there a way in either php or html to disable the back and or the
      > reload/refresh on a browser so a potential spammer cant just keep refreshing
      > the page of a form that sends a confirmation email out[/color]

      In PHP, check the reference page, if the reference page isn't the page from
      where the link is to the send-page, then redirect them to another page that
      wishes them "happy new year".

      //Aho

      Comment

      • Jochen Buennagel

        #4
        Re: stop someone reloading a page

        J.O. Aho wrote:[color=blue]
        > In PHP, check the reference page, if the reference page isn't the page
        > from where the link is to the send-page, then redirect them to another
        > page that wishes them "happy new year".[/color]

        Won't work... When pressing "F5", the browser sends the same referer
        info as before.

        Jochen

        Comment

        • Floortje

          #5
          Re: stop someone reloading a page


          "chris" <someone@here.c om> schreef in bericht
          news:3fea4aaa$1 @funnel.arach.n et.au...[color=blue]
          > is there a way in either php or html to disable the back and or the
          > reload/refresh on a browser so a potential spammer cant just keep[/color]
          refreshing[color=blue]
          > the page of a form that sends a confirmation email out
          >
          > thanks in advance
          >[/color]


          This is what I do

          // put on top of page
          if ($_POST)
          { // do stuff that cant handle refresh
          header("Locatio n: http://".$_SERVER['PHP_SELF']); // with or without
          vars
          exit;
          }





          Comment

          • J.O. Aho

            #6
            Re: stop someone reloading a page

            Jochen Buennagel wrote:[color=blue]
            > J.O. Aho wrote:
            >[color=green]
            >> In PHP, check the reference page, if the reference page isn't the page
            >> from where the link is to the send-page, then redirect them to another
            >> page that wishes them "happy new year".[/color]
            >
            >
            > Won't work... When pressing "F5", the browser sends the same referer
            > info as before.[/color]

            Then next option is to use a cookie, I guess most spammers would use another
            method than a browser to send, on the page before set a cookie, then on the
            sendpage, if there aren't any cookie set, then don't send (and if there is,
            delete cookie and send).


            //Aho

            Comment

            • Shawn Wilson

              #7
              Re: stop someone reloading a page

              Floortje wrote:[color=blue]
              >
              > "chris" <someone@here.c om> schreef in bericht
              > news:3fea4aaa$1 @funnel.arach.n et.au...[color=green]
              > > is there a way in either php or html to disable the back and or the
              > > reload/refresh on a browser so a potential spammer cant just keep[/color]
              > refreshing[color=green]
              > > the page of a form that sends a confirmation email out[/color][/color]

              You could use uniqid() to generate a unique id and include it in hidden field in
              the form. On your confirmation page, check a log file or mysql db to see if
              that confirmation number has been used. If not, send the email and write the id
              to the db or file. If it has been used, display the appropriate error message.
              This is quick and easy and will prevent the casual or inadvertent "spammer" from
              sending multiple emails with refresh and back (though a programmer can get
              around it easily). Make sure to clean out the file or db often or else your
              script will slow down. You can do this manually, with a cron job, or this
              method:

              If using a logfile, if the filesize() is greater than n bytes delete all but the
              last 10 records and save the file. Occasionally, a user will have to wait a bit
              longer (a fraction of a second or, at most, a couple seconds), but you keep all
              your code together.

              Regards,
              Shawn


              --
              Shawn Wilson
              shawn@glassgian t.com

              Comment

              • CountScubula

                #8
                Re: stop someone reloading a page

                At the top of your script/page check for a cookie or session variable

                $varName = session or cookie
                if ($varName == "yep")
                header("Locatio n: http://www.yourdomain. com/noback.html");

                then at this point set a cookie or session variable

                $varName = "yep";
                setcookie or session

                now continue with rest of your page
                if the use tries to come back to this page, nope, no way jose
                the only way back would be through the page that is supposed to link
                to it, and on this page make sure to clear the cookie or session var.

                so your prior page, at top:
                $varName = "all clear";
                setcookie or session


                again, as was stated, a programmer can get past this.

                Mike
                http://gzen.myhq.info -- free online php tools

                Comment

                • php

                  #9
                  Re: stop someone reloading a page

                  Perhaps you could maintain a database by IP address and reject duplicates.

                  The requester IP address is available via a $_SERVER['REMOTE_ADDR']
                  variable.

                  Good Luck.


                  "chris" <someone@here.c om> wrote in message
                  news:3fea4aaa$1 @funnel.arach.n et.au...[color=blue]
                  > is there a way in either php or html to disable the back and or the
                  > reload/refresh on a browser so a potential spammer cant just keep[/color]
                  refreshing[color=blue]
                  > the page of a form that sends a confirmation email out
                  >
                  > thanks in advance
                  >
                  >
                  >[/color]


                  Comment

                  • Cameron

                    #10
                    Re: stop someone reloading a page

                    php wrote:[color=blue]
                    > Perhaps you could maintain a database by IP address and reject duplicates.
                    >
                    > The requester IP address is available via a $_SERVER['REMOTE_ADDR']
                    > variable.
                    >
                    > Good Luck.
                    >
                    >
                    > "chris" <someone@here.c om> wrote in message
                    > news:3fea4aaa$1 @funnel.arach.n et.au...
                    >[color=green]
                    >>is there a way in either php or html to disable the back and or the
                    >>reload/refresh on a browser so a potential spammer cant just keep[/color]
                    >
                    > refreshing
                    >[color=green]
                    >>the page of a form that sends a confirmation email out
                    >>
                    >>thanks in advance
                    >>
                    >>
                    >>[/color]
                    >[/color]

                    You could use the GD lib and create a random number ouputted as an image
                    which has to be inputted into the form and expires as soon as the form
                    as been used, much like a lot of sites do including Yahoo I belive.

                    ~Cameron

                    Comment

                    • neerolyte

                      #11
                      Re: stop someone reloading a page


                      "php" <php@php.info > wrote in message
                      news:Nd0Sb.1257 7$X71.5643@news svr24.news.prod igy.com...[color=blue]
                      > Perhaps you could maintain a database by IP address and reject duplicates.
                      >
                      > The requester IP address is available via a $_SERVER['REMOTE_ADDR']
                      > variable.
                      >
                      > Good Luck.[/color]
                      what about two people behind one proxy? this seems to me like a very bad
                      idea


                      Comment

                      • Eric Bohlman

                        #12
                        Re: stop someone reloading a page

                        "chris" <someone@here.c om> wrote in news:3fea4aaa$1 @funnel.arach.n et.au:
                        [color=blue]
                        > is there a way in either php or html to disable the back and or the
                        > reload/refresh on a browser so a potential spammer cant just keep
                        > refreshing the page of a form that sends a confirmation email out[/color]

                        This sounds like a classic case of an "XY problem" where you want to
                        accomplish task X (e.g. prevent a particular user from sending out multiple
                        emails) and get the idea that implementation Y (e.g. disable the back
                        button) is the way to do it. In most cases, it turns out that
                        implementation Z (e.g. generate some sort of unique identifier with each
                        form, and reject multiple submissions of the form with the same ID), is a
                        better way to accomplish X.

                        Comment

                        Working...