Ross Kendall-Selwyn
Ross Kendall-Selwyn
12,813 Points

Why does form submission does not fire on the first click but does after refreshing and clicking a second time?

I've built a contact form as a side project using PHP. When I complete the form and click submit it moves to the location specified: /index-contact.php?submission but I don't receive the email. If i refresh the page complete the form and click submit again, then i get BOTH emails at once. It's like the first email is waiting for the second email to push it through. Can anyone explain why this is happening?

I'm not quite sure how to add my code in the correct format but:


if (isset($_POST['submit'])) {

$name = $_POST['name']; $subject = $_POST['subject']; $mailFrom = $_POST['mail']; $phone = $_POST['phone']; $address = $_POST['address']; $body = $_POST['body']; $radio = $_POST['time'];

$mailTo = ""; $headers = "From: ".$mailFrom; $txt = "You have recieved an enquiry from: ".$name.".\n\n Phone Number: ".$phone."\n\n Address: ".$address."\n\n Message: ".$body."\n\n Time to call: ".$radio;

mail($mailTo, $subject, $txt, $headers); header("Location: index-contact.php?submission"); }


The HTML markup is generic form markup with a submit button, no AJAX, jQuery etc.