Originally posted by dannys
Just tried with your passwd file - entered 'two' and it came back with the following password (I added ' echo "<br>PasswdInDB was: $passwdInDB";' to the end of the code btw):
PasswdInDB was: $1$PwUeQvVg$PIUIWMaY8rcv3SrhKZLQj1
Which is correct, isn't it?
What happens if you add var_dump($user) to the end of the code?
Hello ,
if I insert "two" I receive this
Passwords don't match!
9IjurpaLgbTiQ
PasswdInDB was: 9IpB2JN0oVAUA
Instead of $1$PwUeQvVg$PIUIWMaY8rcv3SrhKZLQj1
?
If I insert var_dump($user) i receive this ........
Passwords don't match!
9IjurpaLgbTiQ
PasswdInDB was: 9IpB2JN0oVAUAarray(3) { [0]=> string(52) "one:$1$P5ZvyRDb$1Q5A3163ipii4NCoxef3z1:11904:::::: " [1]=> string(52) "two:$1$PwUeQvVg$PIUIWMaY8ucv3SrhKZLQj1:11905:::::: " [2]=> string(33) "three:ZqrYf9Sia4xz6:11906:::::: "
?
I am using this code
<?php
$user ='two';
$password ='onlyatest';
$passwdFile='shadow';
$users=file($passwdFile);
if (!$user=preg_grep("/^$userName/",$users))
{
echo "User '$userName' not found!";
}
else
{
list(,$passwdInDB)=explode(':',array_pop($user));
if (crypt($userPasswd,$passwdInDB) == $passwdInDB)
{
echo "Password verified!";
}
else
{
echo "Passwords don't match! <br>";
echo (crypt($userPasswd,$passwdInDB));
echo "<br>PasswdInDB was: $passwdInDB";
}
}
var_dump($user)
?>
this is the shadow file ;
one:$1$P5ZvyRDb$1Q5A3163ipii4NCoxef3z1:11904::::::
two:$1$PwUeQvVg$PIUIWMaY8ucv3SrhKZLQj1:11905::::::
three:ZqrYf9Sia4xz6:11906::::::
four:9IpB2JN0oVAUA:11912::::::
What's wrong ? Any idea ? Thank you