Created
October 23, 2012 07:43
-
-
Save rioleo/3937494 to your computer and use it in GitHub Desktop.
login.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// A malicious user would be hard-pressed to compromise | |
// a user's password with crypt because crypt is a one-way | |
// function, and the malicious user would also need to guess | |
// the salt, which can be set on an individual-user basis. | |
$salt = "kr"; | |
// This saved_password would be saved in the database. | |
$saved_password = crypt('mypassword', $salt); | |
echo "<p>The saved password is: ".$saved_password."</p>"; | |
$username = $_POST["username"]; | |
$entered_password = $_POST["password"]; | |
echo "<p>The user sent a username of: ".$username ."</p>"; | |
echo "<p>The user sent a password of: ".$entered_password."</p>"; | |
// We check the user-entered password against the one | |
// saved and retrieved above. If it matches, the user is logged in. | |
if (crypt($entered_password, $salt) == $saved_password) { | |
echo "Password verified!"; | |
} | |
echo "<p><a href='index.php'>Go back</a></p>"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment