I have the following html and php codes for my contact form. At first when website was uploaded live it worked. After a few days I noticed the contact form was giving 403 forbidden error on submit. I've changed the file permission to 755 and it worked for a short time and then went back to 403 forbidden. Not sure if something wrong with my php or html. Please help.
HTML Code:
<form action="email.php" method="post">
<div class="col-md-12">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<input type="text" class="form-control" name="first-name" placeholder="First Name">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<input type="text" class="form-control" name="last-name" placeholder="Last Name">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<input type="text" class="form-control" name="email" placeholder="Email">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<input type="number" class="form-control" name="phone" placeholder="Phone">
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<textarea name="message" class="form-control" id="" cols="30" rows="7" placeholder="Message"></textarea>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<input type="submit" value="Send Message" class="btn btn-primary">
</div>
</div>
</div>
</div>
</form>
PHP Code:
<?php
$firstname = $_POST['first-name'];
$lastname = $_POST['last-name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$formcontent="From: $firstname $lastname
Email: $email
Phone: $phone
Message: $message";
$recipient = "main@yaxcheadventuretours.com";
$subject = "Contact Form from $firstname $lastname";
$mailheader = "From: $firstname $lastname $email
";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo'
<script>
window.onload = function() {
alert("Thank You for reaching out to us!");
location.href = "contact.html";
}
</script>
';
?>