嗨,我以前曾经成功地使用过这个非常简单的php联系人脚本,但是当我尝试在新HTML页面上实现该表单时,它不会提交.谁能看到任何明显的错误?
任何帮助将非常感激
这是表格的html:
Your details
Name *
Email *
Telephone
Tutoring
Type of lesson
Individual
Group
Subject
English
Biology
Geography
Your level
Beginner
GCSE
A-Level
University
Hours/week
Additional Information
这是简单的php脚本:
if ($_POST["email"]<>'') {
$ToEmail = 'onjegolders@gmail.com';
$EmailSubject = 'Site contact form ';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name: ".$_POST["name"]."
";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."
";
$MESSAGE_BODY = "Telephone: ".$_POST["tel"]."
";
$MESSAGE_BODY = "Type: ".$_POST["type"]."
";
$MESSAGE_BODY = "Subject: ".$_POST["subject"]."
";
$MESSAGE_BODY = "Level: ".$_POST["level"]."
";
$MESSAGE_BODY = "Hours required: ".$_POST["hours"]."
";
$MESSAGE_BODY .= "Additional information: ".nl2br($_POST["info"])."
";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
?>
Thanks for your email
I'll get back to you as soon as possible
Click here to go back to previous page
} else {
?>
Sorry, this form didn't work
};
?>
解决方法:
试试看
if ( !empty($_POST["email"]) )
但是,您可以使用以下方法检查该页面上发布的内容:
echo '
';
var_dump( $_POST );
标签:contact-form,html5,php
来源: https://codeday.me/bug/20191102/1993525.html