ar************* *@gmail.com wrote:
Hi,
I'm learning PHP and prepared a simple login form. validate.php does
the validation and it was behaving erratically. So, I did var_dump of
$_POST variable and it's NULL. Did I miss anything here regarding the
configuration or code? Code for validate.php is given below.
<?php
var_dump($_POST );
$user=$_POST['login'];
$password=$_POS T['password'];
// .... Rest of the validation ...
?>
Any kind of help would be highly beneficial.
Odds are your problem is with your html. Double-check your variable
names in the html form as well as in your php source. Also, check your
form tag in your html. You may inadvertantly be using GET instead of
POST, in which case $_POST will contain nothing. Also, update to the
latest stable release of PHP. See below for an example.
test.html:
<form action="login.p hp" method="POST">
Username: <input type="text" name="user"><br >
Password: <input type="password" name="password" ><br>
<input type="submit" value="Submit">
</form>
login.php:
<?php
$user = isset($_POST['user']) ? $_POST['user'] : '';
$pass = isset($_POST['password']) ? $_POST['password'] : '';
echo 'Username: '.$user.'<br>Pa ssword: '.$pass;
?>