Jump to content
Larry Ullman's Book Forums

Chapter 9, Script 9.7, Password.Php Dup Password


Recommended Posts

If I entered the same new password as the old password, an error occurred that didn't inform the user of this. The following code can be changed as needed. CU

 

I added the following code that checks for duplicate old and new passwords:

 

 

//-------------------------------------------------------------------------

// Check to see if password the same

$q = "SELECT user_id FROM users WHERE (email='$e' AND pass=SHA1('$np') )";

$r = @mysqli_query($dbc, $q);

$num = @mysqli_num_rows($r);

if ($num == 1) {

//echo 'Not OK' . ' ' . $num; // for testing.

$errors[] = 'Your new password is the same as your old password.';

}

//-------------------------------------------------------------------------

 

if (empty($errors)) { // If everything's OK.

Link to comment
Share on other sites

 Share

×
×
  • Create New...