我使用HTML创建了一个联系表单,但在尝试提交表单时总是出错。我不知道php,但我做了很多研究并检查了没有语法错误。
我已检查过电子邮件地址是否正常运行。
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");
}
}