I'm testing a contact from with the submission on the local server. dev.localhost
The error I'm getting is
The requested URL /volunteer-success.php was not found on this server.
I'm new to PHP. I'm trying to submit a form, email the message+name, and then redirect the user to a thankyou screen.
My HTML is as follows...
<form action="volunteer-submit.php" method="post" name="contact_form" data-parsley-validate>
<textarea name="message" id="message" placeholder="Message" required></textarea>
<input type="text" placeholder="Your Name" id="name" name="name" required>
<input type="email" placeholder="Your Email Address" id="email" name="email" required>
<input type="submit" class="submit" value="Submit">
</form>
The PHP for sending the email is as follows
$to = "[email protected]";
$subject = 'Email';
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: '.$_POST["email"]. "\r\n" .
"Content-Type: text/html; charset=ISO-8859-1\r\n".
'X-Mailer: PHP/' . phpversion();
$message = '<html><head><title></title></head><body>';
$message .= '<p>Hi Ben, </p>';
$message .= '<p>'.$_POST['message'].' </p>';
$message .= '<p>'.$_POST['email'];
$message .= '</body></html>';
mail($to, $subject, $message, $headers);
//Redirect
header("Location:volunteer-success.php"); /* Redirect browser */
?>
Would love to know why it's not redirecting. I've saved the php files alongside the index.html file onto the dev.localhost.
*example emails used
Location:, which you don't have in your example code, maybe that's the error. - nonchip