Support » Fixing WordPress » Posting a <form> to the same page returns a 404

  • I have this code on page.php

    <?php 
    
    	if(array_key_exists('form', $_POST)) {
    
    		$name = $_POST['name'];
    
    		echo $name;
    
    	} else {
    
    ?>
    
    <form action="" method="post">
    
         <p>Name<br />
    	<input name="name" type="text"></p>
    
         <input name="form" type="hidden" />
    
    </form>
    
    <?php } ?>

    But when the page is submitted it returns a 404 error, despite the URL being identical between pages. I understand this must have something to do with WordPress querying the page but does any have any idea to get this to work?

Viewing 1 replies (of 1 total)
  • I’ve just noticed that if I submit the form without a value in the input ‘name’ the form processes and I don’t get a 404.

    Odd!

Viewing 1 replies (of 1 total)
  • The topic ‘Posting a <form> to the same page returns a 404’ is closed to new replies.