Reputation: 333
I want to make this registration script tell the user when the passwords they have entered are not matching.
and i use this code:
if ($_POST['pass' != 'pass2'])
{
echo
("Oops! Password did not match! Try again. ");
}
please help me to correct my coding. :-( thanks so much!
Upvotes: 3
Views: 41647
Reputation: 1235
You should also check if the passwords were not left empty or if they are not just blank spaces. Otherwise, two uncompleted fields are valid.
if(trim($_POST['pass'])=='' || trim($_POST['pass2'])=='')
{
echo('All fields are required!');
}
else if($_POST['pass'] != $_POST['pass2'])
{
echo('Passwords do not match!');
}
Upvotes: 2
Reputation: 812
Inside the post you cannot reference both. So try this:
if(($_POST["pass"])!=($_POST["pass2"])){
echo"Oops! Password did not match! Try again.";
}
Upvotes: 1
Reputation: 333
if ($_POST['pass']!= $_POST['pass2'])
{
echo("Oops! Password did not match! Try again. ");
}
.. i will use this code. and it also works. :-)
.. thanks for helping.
Upvotes: 3
Reputation: 11529
You can't reference both the variables inside the same $_POST
if ($_POST['pass']!= $_POST['pass2'])
{
echo("Oops! Password did not match! Try again. ");
}
Upvotes: 10