所以我在WordPress页面中构建了一个表单,如下所示:
<form action="/help" method="GET">
<h2 class="heading post-title">Contact Us</h2>
<label>Name:</label><br>
<input type="text" name="name" /><br>
<label>Email:</label><br>
<input type="text" name="email" /><br>
<label>Subject:</label><br>
<input type="text" name="subject" /><br>
<label>Message:</label><br>
<textarea name="msg" style="width:200px;height:380px"></textarea><br><br>
<input type="submit" style="width:206px;margin:0 auto;border:1px solid gray;border-radius:3px;background-color:orange;color:white" />
<br>
<label style="color:red"><?php if(isset($_GET[\'success\'])) echo "Your message has successfully been sent!"; else echo "<br>"; ?></label>
</form>
和/帮助重定向到包含此代码的同一页面,因此我尝试将该页面重定向到自身
包含上述表单(page help.php)的同一页面,在开始时也包含一些用于处理数据的php,如下所示:
<?php
if(isset($_POST[\'message\']))
{
// require \'PHPMailerAutoload.php\';
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = \'mail.arkzel.com\'; // Specify main and backup server
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = \'[email protected]\'; // SMTP username
$mail->Password = \'Xwbs*YR!\'; // SMTP password
$mail->SMTPSecure = \'tls\'; // Enable encryption, \'ssl\' also accepted
$mail->From = $_POST[\'email\'];;
$mail->FromName = $_POST[\'name\'];;
$mail->addAddress(\'[email protected]\'); // Name is optional
$mail->WordWrap = 50; // Set word wrap to 50 characters
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $_POST[\'subject\'];;
$mail->Body = $_POST[\'message\'];
$mail->AltBody = \'This is the body in plain text for non-HTML mail clients\';
if(!$mail->send()) {
echo \'Message could not be sent.\';
echo \'Mailer Error: \' . $mail->ErrorInfo;
exit;
}
header("location: help?success=1");
}
?>
但是,我得到的是一条404:找不到的消息<非常困惑。