I’ve just tried that and can’t reproduce the problem. Here’s the code I used:
<?php
/*
Template Name: Form
*/
?>
<?php get_header(); ?>
<?php echo ‘We have got: ‘ . $_POST[‘f1’] . ”; ?>
<form action=”” method=”POST”>
<input type=”text” name=”f1″ value=”test”/>
<input type=”submit” name=”submit” value=”Submit”/>
</form>
<?php get_footer(); ?>
Submitting the form shows the value of the input field as expected; no 404.
Maybe a plugin that’s interfering here. Have you tried this on a fresh installation?
Hi chschenk, and thanks for looking into the problem for me. Your form worked for me so I started looking at my own form. Turns out the problem was caused by one of my input’s being called ‘name’. Try this:
<?php
/*
Template Name: Form
*/
?>
<?php get_header(); ?>
<?php echo 'We have got: ' . $_POST['name'] . ''; ?>
<form action="" method="POST">
<input type="text" name="name" value="test"/>
<input type="submit" name="submit" value="Submit"/>
</form>
<?php get_footer(); ?>
On my WordPress install this produces a 404 error page.
I get a 404 here too but can’t tell whether that happens; excuse: haven’t had a detailed look at it.
I’d say, just avoid naming your input fields “name” 😉
Thanks – I was using the post names of “author”, “title” and “description” and was getting this error. I modified them to “ad_author”, “ad_title”, (I’m making a simple classifieds board for our intranet) and that took care of it.
Thanks for the tip! – I would call this resolved.
Thanks! Searched a long time for a solution to this problem, and now I found it on this page… name=”name” 🙂
Thanks guys. Weird, but thanks for the answer.