我对这一切都很陌生,需要帮助......我有一个我想发送的论坛,但由于某种原因它没有发送。mailto 函数不会在服务器上发送电子邮件,也不会刷新到 redirect.html。这是我的代码:
<?php
$problem = FALSE;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (empty($_POST['name'])) {
$problem = TRUE;
print '<p class="important">• What is your name?</p>';
}
if (empty($_POST['email'])) {
$problem =TRUE;
print '<p class="important">• What is your email?</p>';
}
if (empty($_POST['message'])) {
$problem =TRUE;
print '<p class="important">• What is your message?</p>';
}
if ($problem = TRUE) {print '<br />';}
}
?>
<form action="index.php" id="contact_me" method="post">
<table border="0" cellspacing="0" cellpadding="0" width="500">
<tr>
<td width="160">Your Name:<span class="important">*</span></td>
<td width="340"><input name="name" type="text" size="30" value="<?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (isset($_POST['name'])) { print htmlspecialchars($_POST['name']); }}?>"/>
</td>
</tr>
<tr>
<td><p>Your Email:<span class="important">*</span></p>
</td>
<td><input name="email" type="text" size="30" placeholder="example@example.com" value="<?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (isset($_POST['email'])) { print htmlspecialchars($_POST['email']); }}?>"/></td>
</tr>
<tr>
<td>Message:<span class="important">*</span></td>
<td><textarea name="message" rows="6" cols="40" placeholder="Your message here"><?php if($_SERVER['REQUEST_METHOD']=='POST'){if(isset($_POST['message'])){print htmlspecialchars($_POST['message']);}}?></textarea></td>
</tr>
</table><br />
<input type="submit" name="submit" id="submit" value="Submit" >
</form>
<?php
// Start the email function
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($problem == FALSE) { // holy cow they didn't mess up
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$message=$_REQUEST['message'];
$from="From: $name<$email>\r\nReturn-path: $email";
$subject="Mathew Blair - Contact form";
mail("mathewblair@live.com", $subject, $message, $from);
Header("Location: redirect.html");
}
}
?>
谢谢您的帮助!