0

I created a contact form with HTML but I always get an error when trying to submit the form. I don't know php but I have done quite a research and checked that there are not syntax mistakes.

I have checked that the email address is working properly.

HTML

   <form action="mail.php" id="form" method="post" name="form">
      <input id="name" name="name" type="text">
      <input id="email" name="email" type="text">
      <textarea id="msg" name="message"></textarea>
      <a href="javascript:%20check_empty()" id="submit">Send!</a>                
    </form>

PHP

<?php $name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name \n Message: $message";
$recipient = "info@tanie-przeprowadzki-warszawa.pl";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!" . " -" . "<a href='index.html' style='text-decoration:none;color:#ff0099;'> Return Home</a>";
?>

JAVASCRIPT VALIDATION FORM

function check_empty(){
    if (document.getElementById('name').value == "" || document.getElementById('email').value == "" || document.getElementById('msg').value == "") {
        alert("Fill All Fields!");
    } else {
    document.getElementById('form').submit();
        alert("Form Submitted Successfully");
    }
}
Alvarado87
  • 115
  • 9

0 Answers0