我的联系表格有问题。当我在我的网站上填写时,我会收到一封电子邮件,但我收到的电子邮件中的字段:姓名、电子邮件和消息保持空白。
我的联系方式包括:(contacts.html
我网站上的 html 页面);contactengine.php
(实际形式);thanks.html
(当问题成功发布时打开);unsuccessful.html
(不成功时打开)。
谁能告诉我这段代码有什么问题?
联系人.HTML
<form id="form" form action="contactengine.php" method="post" >
<fieldset>
<label><input type="text" name="cf_name" value="Name" id="cf_name" onBlur="if(this.value=='') this.value='Name'" onFocus="if(this.value =='Name' ) this.value=''"></label>
<label><input type="text" name="cf_email" value="e-Mail" id="cf_email" onBlur="if(this.value=='') this.value='e-Mail'" onFocus="if(this.value =='e-Mail' ) this.value=''"></label
<label><textarea name="cf_message" id="cf_message" onBlur="if(this.value==''){this.value='Message'}" onFocus="if(this.value=='Message'){this.value=''}">Message</textarea></label>
<div class="btns">
<a href="contacts.html" class="link-1">Cancel</a>
<a href="contactengine.php" class="link-1" onClick="document.getElementById('form').submit()">Submit</a></div>
</fieldset>
</form>
联系方式.PHP
<?php
$EmailFrom = "form@mysite.rs";
$EmailTo = "office@mysite.rs";
$Subject = "Message from website";
$cf_name = Trim(stripslashes($_POST['Name']));
$cf_email = Trim(stripslashes($_POST['Email']));
$cf_message = Trim(stripslashes($_POST['Message']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=unsuccessful.html\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $cf_name;
$Body .= "\n";
$Body .= "e-Mail: ";
$Body .= $cf_email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $cf_message;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=thanks.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=unsuccessful.html\">";
}
?>