WordPress.org

Forums

Posting a <form> to the same page returns a 404 (2 posts)

  1. nouveller
    Member
    Posted 5 years ago #

    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?

  2. nouveller
    Member
    Posted 5 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.