here’s my problem :
I have a .php file within my wordpress that do the following thing :
- with a form asks a NAME and to the user
- posts the data to this same page (action=””)
- if NAME is not empty, then do something, else ask for the NAME again
Here’s the code :
function loginForm(){
echo'
<div id="loginform">
<form action="" method="post">
<p>Please enter your name to continue:</p>
<label for="name">Name:</label>
<input type="text" name="name" id="name" />
<input type="submit" name="enter" id="enter" value="Enter" />
</form>
</div>
';
}
if(isset($_POST['enter'])){
if(isset($_POST['name']) && $_POST['name'] != ""){
//do smth
}
else{
echo '<span class="error">Please type in a name</span>';
}
}
But here’s the problem : when i click without entering any name, then it’s fine, it works as expected : it returns the same page with an error message. HOWEVER, if I enter any name, it returns me “Page Not Found”, and the POST request fails (404)
What could be happening so such a thing happens ?
PS : excuse me for my probably bad english
This will cause issues specific to wordpress, it is a reserved field name.
so change the name.
Should work with no problems.
in WordPress you need to specify an
action
. This should work: