I set up this test page up on my server. Please tell me why the $_POST
array does not contain anything even when I submit the form. I have tried this in three different browsers and nothing happens.
<?php print_r($_POST);?>
<form method="post">
<p><label>Email: </label>
<input type="text" id="login_email" />
</p>
<p><label>Password: </label>
<input type="password" id="login_password" />
</p>
<p><label>Remember Me?: </label>
<input type="checkbox" id="login_remember" />
</p>
<p>
<input type="submit" value="Login" />
</p>
</form>
I have been writing PHP for years and this has never happened before. What is wrong with this code?
Your input elements do not have name attributes. Should be:
<input type="text" id="login_email" name="login_email" />
If an input element does not have a name attribute, it is not sent as part of the POST data.
Well, you don't have an action for the form tag? It should be the script name:
<form method="post" action="scriptname.php">
...and you're also not setting the names for each form input - the browser doesn't submit the ID as the element name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With