WordPress Returning 404 Page When Submitting Custom Form

March 25th, 2013 - Posted by Steve Marks to (X)HTML / CSS, PHP, Web Development.

There are lots of plugins available for WordPress that allow you to quickly and easily embed forms within a website. Sometimes however, you may need to build a standard form that submits the same as a non-WordPress site.

I needed to do exactly this today. I built the form’s HTML, made it submit to itself (ie. the same URL) and coded some PHP to process the form. When the form was submitted however, it just went a 404 page straight away.

I knew the page existed because the form was posting to the same URL, and I knew it was OK to POST data from a form, so what was the problem?

The Solution

In summary, WordPress has a list of reserved words for POST variables that can’t be used when building a bespoke form. In my scenario one of the textboxes had the name of ‘name‘, which turned out to be one of these reserved words.

I don’t have a definitive list of these reserved words, however I did find a full list here.

Once I used a different name for the text field in question, my form then began to submit as expected.

This entry was posted on Monday, March 25th, 2013 at 2:17 pm by +Steve Marks and is filed under (X)HTML / CSS, PHP, Web Development. You can follow any responses to this entry through the RSS 2.0 feed.

Fear not, we won't publish this

Comments (0)

No comments have been left yet. Be the first