How to prevent reposting of values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KeredDrahcir
    Contributor
    • Nov 2009
    • 426

    How to prevent reposting of values

    I'm working on a php program and I need to post values and use the posted values to update the session vaiables but if a user clicks back or refresh it can repost the values and since the values need to be incremented to I add them on, if this happens them it can upset the values.

    Is there a way to prevent this from happening?
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    No. You need to code with this mind. (i.e. the user can ping your page multiple times). You must code to not upset your values.


    DM

    Comment

    • KeredDrahcir
      Contributor
      • Nov 2009
      • 426

      #3
      If I set a session variable and a user clikcs on refresh, or back, what happens to the session variable. Does it stay the same?

      Comment

      • KeredDrahcir
        Contributor
        • Nov 2009
        • 426

        #4
        Can anuone help me with what happens to session variables when you clikc back or refresh?

        Comment

        • dlite922
          Recognized Expert Top Contributor
          • Dec 2007
          • 1586

          #5
          it stays the same.

          Read the PHP manual: http://us3.php.net/manual/en/intro.session.php

          Dan

          Comment

          • KeredDrahcir
            Contributor
            • Nov 2009
            • 426

            #6
            Okay thanks. In that case I can set the a session varuable that will increment when it loads the next function and then if they click back, or refresh, it will be a wrong number and it will know not to change any values.

            Do you think that will work?

            Comment

            • KeredDrahcir
              Contributor
              • Nov 2009
              • 426

              #7
              Is there anything I can do to prevent values from being reposted using JavaScript or is there anything I can do using JavaScript thatg will tell me if they've just clicked on Refresh or Back aso I can undo a multiple submission.

              Comment

              • Chris T
                New Member
                • Jul 2011
                • 5

                #8
                try to use ajax + jquery form submit implementation. Even if a user clicks on back or refresh the page it won't send that values.

                Comment

                • KeredDrahcir
                  Contributor
                  • Nov 2009
                  • 426

                  #9
                  I'm going to store the ID number of the function in a Session variable. Then if they click refresh of back there will be a mismatch. Is there any other way a mismatch could occur or could this work?

                  Comment

                  Working...