Stumbled across this problem recently and thought it worth sharing, for anyone who’s trying to set up a form on wordpress and on submission gets a 404 error.
Recently we set up a contact form for a client on their wordpress blog. Many people simply use one of the numerous plugins available to achieve this, but the client wanted some particular customisation for this form so we decided to set up a page template to handle the contact form.
All well and good, until the form gets submitted (regardless of where the action is pointed). Some scratching of heads ensued, as we tested the form independently of wordpress. This post on the wordpress support site gave an indication of the problem. Using the field ‘name’ was causing all to go awry. Change your field name to something like cname and the form works fine.
Great – that’s a solution, but why does it happen? Well, you can get the answer quickly by adding to your form template. Load the page and you’ll see that $name is a variable already used by WordPress for the slug, or the part of the url specific to a given page when using the customised permalinks structure. When you assign a field the id of ‘name’ you send wordpress looking for a page that doesn’t exist, hence your 404 error.