So i'm currently facing a problem. I working with a POST/REDIRECT/GET method for all my submit forms that goes like this:
post.php
if ($_SERVER['REQUEST_METHOD'] == 'POST'):
switch ($_POST['submit']):
case 'MyButtonName1':
$_SESSION['postdata'] = $_POST;
$postdata = $_SESSION['postdata'];
unset($_POST);
// my code actions here
// After my code actions completed
$_SESSION["success"] = "Form submit was successfully";
header("Location: /myscript/");
unset($postdata);
exit();
break;
case 'MyButtonName2':
// some code here and same proccess as above but for some other form then
break;
endswitch;
exit();
endif;
form.php
<form method="POST" action="/post/">
// Some input fields here
<button type="submit" name="submit" value="MyButtonName1">Submit button</button>
</form>
Everything works perfect like this, but the problem that i am having right now is: When someone submitting the form in a normal way with just 1 click it will process the form normally and validate the data, unset the postdata, and redirect then back to the page, or to a different page if needed so. The issue now in my case is: When someone placed an order on my site and has picked the payment processor, it will then redirect to the payment screen thats on a different page so that to customer can complete the order. But what happens now is when someone would click rapidly click the button few times, it will still make that first charge and normally redirect to the payment screen but because of the fast button presses it skips the redirect to this page and will return back and then say you need to fill in your information first..
So now i'm looking for a way on how to disable the button and then resets again after the redirect has been made first, or other ways. I have tryed some javascript solutions but since my POST happends in a different page, it doesn't work.
I hope you understand a little bit what i am trying to say, my english isn't the very best..