So… I have a form build into a WordPress page like this:
<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>
And /help redirects to the same page which contains this code, so I’m trying to redirect the page to itself.
Same page which contains the form above (page-help.php), also contains some php in the beginning for processing the data, like this:
<?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 = 'arsham@arkzel.com'; // 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('arsham@arkzel.com'); // 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");
}
?>
But instead, what I get is a 404: Not Found message.
Much confused.
Rename your form fields so they don’t clash with WordPress query vars, specifically
name
.Reserved
$_GET
and$_POST
terms in WordPress:Source: http://codex.wordpress.org/Function_Reference/register_taxonomy#Reserved_Terms