WordPress Returning 404 Page When Submitting Custom Form
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?
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.