我已经为一个站点建立了一个 PHP 联系表。服务器启用了邮件程序,代码将不会执行。我没有收到任何解析错误。关于调试的任何建议或问题是什么?
//Check the form submission
if (isset($POST['submitted'])){
//validate the form
if(!empty($_POST['name']) &&
!empty($_POST['email']) &&
!empty($_POST['comments']) ){
//Create the body
$body = "Name:
{$_POST['name']}\n\nComments:
{$_POST['comments']}";
//Make the Name no longer than 70 Characters
$body = wordwrap($body, 70);
//Send the email
mail('xxx@xxxx.com',
'Contact Form Submission',$body,
"From: {$_POST['email']}");
//Print the Thank You message
echo'<p>Thank you for contacting us we appreciate your interest</p>';
//Clear $_POST so that its not a sticky form
$_POST = array();
} else {
echo'<p>Please fill out the form completely.</p>';
}
}// End of main isset ()IF
表格代码是
<div id="wrapper">
<p>Please fill out this form to contact us.</p>
<form action="contact.php"method="post">
<p>Name: <input type="text" name="name"size="30"maxlength="60"value="<?php if(isset($_POST['name']))echo $_POST['name']; ?>" /></p>
<p>Email Address: <input type="text" name="email"size="30"maxlength="80"value="<?php if(isset($_POST['email']))echo $_POST['email']; ?>" /></p>
<p>Comments: <textarea name="comments"rows="5"cols="30"><?php if(isset($_POST['comments']))echo $_POST['comments']; ?></textarea></p>
<p><input type="submit" name="submit" value="Send" /> </p>
<input type="hidden" name="submitted" value="TRUE"/>
</form>
</div>