I'm new to PHP and I'm making a contact form for my website. However whenever I fill out and submit the form it leads me to a blank page and I never receive an email. I have tested it when my website is live. My host is infinity free if it matters.
I tried troubleshooting such as making minor modifications to the code (changing a few names, etc.) Nothing worked.
<html>
<section id="contact">
<div class="container-contact">
<div style="text-align:center">
<h3> Contact Me </h3>
<p> I will get back to you shortly. </p>
</div>
<div class="row">
<div class="column">
<form id="contact-form" method="post" action="contactform.php">
<label for="firstname">First Name</label>
<input type="text" id="firstname" placeholder="Your first name..." required>
<label for="lastname">Last Name</label>
<input type="text" id="lastname" placeholder="Your last name..." required>
<label for="email">Email Address</label>
<input type="email" id="email" placeholder="Your email..." required>
<label for="message">Message</label>
<textarea id="message" name="message" placeholder="Write your message..." style="height:170px" required></textarea>
<input type="submit" name="submit" value="Submit">
</form>
</div>
</div>
</div>
</section>
</html>
<?php
$firstname = $_POST['firstname']
$lastname = $_POST['lastname']
$user_email = $_POST['email'];
$message = $_POST['message']
$email_from = 'myemail@domain.com'
$email_subject = "New Form Submission from $firstname.\n";
$email_body = "First Name: $firstname.\n".
"Last Name: $lastname.\n".
"Email: $user_email.\n".
"Message: $message.\n";
$to = "myemail@domain.com";
$headers = "From: $email_from \r\n";
$headers .= "Reply To: $user_email \r\n";
mail($to,$email_subject,$email_body,$headers);
header("Location: contact.html");
?>
Τhe HTML file name is contact.html and the PHP file is contactform.php
The form doesn't submit and I don't receive an email. Am I doing something wrong? Do I need to setup something else?
Thanks in advance,
Thomas