SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Passing/ re-inserting while hitting refresh

    How to prevent value being passed and being inserted into the database by hitting the REFRESH or the BACK button?
    Trigger8

    **************************
    I killed a 6-pack just to watch it die!

  2. #2
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Let me put it this way -- How to prevent refresh from resubmitting form data?
    Trigger8

    **************************
    I killed a 6-pack just to watch it die!

  3. #3
    SitePoint Enthusiast Atrus's Avatar
    Join Date
    Aug 2001
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi!

    Are you authenticating your submitting party in some way? Let's just say you do and this is some kind of bulletin board:

    On first submit the most recent submission time (regarding a user) is saved in her/his profile. Then just block the user from submitting more within the next 5 seconds. This should keep off most accidential double submissions.

    .....

    EDIT: Ok, forget, what I started above, I just saw your second post come in:
    One answer could be: Use the POST method. Browsers will ask users in this case whether the page shall be retrieved again by submitting another time OR NOT.

    Atrus.
    Webmaster - Stefan Meier KG TABAKWAREN - Pfeifen, Premium-Zigarren, ... (_Ger)

  4. #4
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I do use POST, and the browser also asks user whether they wanna resubmit the information or not. IS there anyway to eliminate that being happened, too?
    Trigger8

    **************************
    I killed a 6-pack just to watch it die!

  5. #5
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thats not a solution as users can still click refresh. My solution would be to do as follows. After submitting data successfully, use header() to send them either to a new page or to the same page passing some variable to skip the inser tstuff and show some thank you message. Something like.






    PHP Code:
    if($submit) {
    $result mysql_query(insert some data);
    }
    if(
    $result) {
    header("Location: $PHP_SELF?submitted=yes");

    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  6. #6
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sounds like a winner!
    Trigger8

    **************************
    I killed a 6-pack just to watch it die!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •