If you have a multi-user website then it is probably good that you have good encryption methods. This tutorial will explain how to encrypt these passwords and then match them with un-encrypted strings when the user comes back. First, you need to encrypt it. This is fairly simple.
<? $password = crypt("abc123"); ?>
Now, lets say you have a user login. So does the user have to put in all those characters and everything? No. They'll just have to put in abc123. It's up to you to match it with the encrypted password and here's how to do it:
<?
$cryptpass = crypt("abc123"); // this is just an example,
//normally you would grab this out of the database
$password = $_POST['password']; // this is assuming you're having abc123 sent via a form
if(crypt($password, $cryptpass) == $cryptpass){ echo 'success'; }
else {
echo 'password incorrect.';
}
?>
Comments
Post new comment