Forum Moderators: coopster
I have a form collecting user data for registration.
the password field and another field to confirm the value typed in by user are defined as follows:
$pwd = strip_tags(trim($_POST['pwd'])); // password typed in
$conf_pwd = strip_tags(trim($_POST['conf_pwd'])); // same password to confirm the password
// checking both fields:
if(strlen($pwd) < 6) {
$message[] = "Password must be at least 6 characters .";
if($pwd != $conf_pwd)
{
$message[]="Your password don't match";
}
If I type in both fields for example "Helloworld" in the same case sensitive manner, I keep getting:
"Password must be at least 6 characters"
"Your passwords don't match"
This is strange since the two passwords are exactly the same.
I tried with something different to see if I can find a match of the two like this:
if(strlen($pwd) != strlen($conf_pwd)) {
$message[] = "Your passwords don't match.";} // this is of course to check because there would be a match with two different paswwords with same length.
This gives the second error message also.
I tried also:
if(!preg_match($pwd,$conf_pwd))
{
$message[]="Your passwords don't match,";
}
and the error is always the same: "Your password don't match".
It's running me crazy and I don't know what to do further.
Any help please,
Yours
Check if the values are really passed, or what is exactly being compared.
$pwd = strip_tags(trim($_POST['pwd'])); // password typed in
$conf_pwd = strip_tags(trim($_POST['conf_pwd']));
echo "Password". $pwd ."<br>";
echo "Confirm Password". $conf_pwd ."<br>";