Contact form problem, html and php
I am using Dreamweaver cc for the following simple contact form which is saved in index.html and I created a mail.php file both saved to -public.html along with styles.css (server is Hostgator.)
The form is simple but looks fine, but the form will not send.
{"code":"MethodNotAllowed","message":"POST is not allowed”} see mail.php below:
Can someone please advise me on what I have done incorrect?
index.html
<!-- fourth container contact section -->
<div class="container-fluid bg-2 text-center" id="Contact">
<div class = "container">
<div class = "contact-content flex">
<div class = "contact-left">
<div class="title">
<h3 class="ontop">Contact</h3><br>
</div>
<form action="mail.php" method="post">
<input type = "text" class = "form-control" placeholder="Your name here ...">
<input type = "email" class = "form-control" placeholder="Your email here">
<br>
<input type = "submit" class = "btn-submit btn" value = "Submit">
</form>
</div>
<!-- end of contact section —>
Mail.php file
I have the following code from https://www.php.net/manual/en/function.mail.php, but not sure how to change it to fit my simple form. I have tried changing it to suit the contact form details: $to to $text = ‘Your name here’, $subject to $email=‘Your email here’ and $message to $Submit, $headers=‘I used my website.com' and ‘Reply-To: myemail@HostGator.com, but once saved and pressed submit, it opens into a new window with a message {"code":"MethodNotAllowed","message":"POST is not allowed"}
<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
I have contacted HostGator who said that it was not their problem and could not help and that I should contact the web developer, but as I am putting my own website together then that advice was not useful for me.
I hope someone can give me some help on this.
Thank you
