How to Process Form Request

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:

Read More
<?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.

Related posts

1 comment

  1. Rename your form fields so they don’t clash with WordPress query vars, specifically name.

    Reserved $_GET and $_POST terms in WordPress:

    attachment
    attachment_id
    author
    author_name
    calendar
    cat
    category
    category__and
    category__in
    category__not_in
    category_name
    comments_per_page
    comments_popup
    customize_messenger_channel
    customized
    cpage
    day
    debug
    error
    exact
    feed
    hour
    link_category
    m
    minute
    monthnum
    more
    name
    nav_menu
    nonce
    nopaging
    offset
    order
    orderby
    p
    page
    page_id
    paged
    pagename
    pb
    perm
    post
    post__in
    post__not_in
    post_format
    post_mime_type
    post_status
    post_tag
    post_type
    posts
    posts_per_archive_page
    posts_per_page
    preview
    robots
    s
    search
    second
    sentence
    showposts
    static
    subpost
    subpost_id
    tag
    tag__and
    tag__in
    tag__not_in
    tag_id
    tag_slug__and
    tag_slug__in
    taxonomy
    tb
    term
    theme
    type
    w
    withcomments
    withoutcomments
    year
    

    Source: http://codex.wordpress.org/Function_Reference/register_taxonomy#Reserved_Terms

Comments are closed.