I have a problem with my page. I’m trying to make a “Contact Us” page. It’s working perfectly fine design-wise. But when I try to send the form to the same page as origin. It returns 404 error.
It only happens when I’m sending the form. I’ve tried both with GET and POST requests. Nothing seems to work.
I’ve even commented out the PHPMailer part. It’s caused entirely by the extra variables.
If it helps anything, they’re “name”, “email” and “message”.
Prefix everything, especially your variables. The names you are using are used by WordPress internally (see the comment form), so WordPress might try to do something with your form values. If that fails you get an error.
While
$_GET
problems are usually rather easy to debug,$_POST
and$_REQUEST
names are not so simple.The following list is probably not complete. But its bare length tells us a lesson:
Avoid any name you can find in a dictionary. Prefix your form names.
List of reserved names in
$_POST
and$_REQUEST
used by WordPress 3.5These names might have side effects when used in themes or plugins. Some are used on specific pages only (
removeheader
), others on multiple pages or requests. Avoid them all if you can.Variable names
Alternatively you could post it to WP and handle the processing in functions.php.
For the form:
And include a hidden input which tells WP what is the function with which you’ll be processing it:
Write the function in functions.php:
Tell WP what is the function: