Is it possible to cancel a session if a user clicks 'refresh'? I don't want users to click refresh and resend data. Thanks in advance Sorry for the repost but I didn't realize there was a PHP sub-board; you can delete the original thread if you want.
Yes, and no...Using a captcha might work just right Because if the captcha doesn't match the session's data, it will void and you can from there say "session expired" But just normally doing it, no you really cant. I might be wrong, but as far as I know, you can't.
Redirect them using PHP's header("Location: wherever") after you parse the POST data so that if they do refresh, it refreshes that new page and doesn't try to resend the POST data. This is the best method I can think of other then setting a hidden input with a hash that is stored as a $_SESSION var and then deleted once they submit so if they refresh again, that hidden hash won't match up and it won't do anything. This would be the same as running a CAPTCHA only the person doesn't actually have to enter it.
The problem is, I'm redirecting to the same page so I don't think the header method will work in this case. How can I do this? It sounds like it will work with a single page.
It works if you use header() to redirect to the very same page after submitting. Did you try? First try and then say anything about this.
You can use sessions to prevent a refresh, yes: <?php session_start(); if (empty($_SESSION['namehere'])) { // let them do what they want here $_SESSION['namehere'] = 'value'; session_write_close(); } else { // Hey, the session is written, so they must have already done this before! } ?> PHP: I hope this helps!