Logging in with sha1() encryption.
Posted
by
Samir Ghobril
on Stack Overflow
See other posts from Stack Overflow
or by Samir Ghobril
Published on 2011-01-12T18:11:49Z
Indexed on
2011/01/12
19:53 UTC
Read the original article
Hit count: 177
Hey guys, I added this to my sign up code :
$password=mysql_real_escape_string(sha1($_POST['password']));
and now it inserts the password into the database while its encrypted. But signing in doesn't seem to work anymore. Here is the login code.
function checklogin($username, $password){
global $mysqli;
$password=sha1($password);
$result = $mysqli->prepare("SELECT * FROM users WHERE username = ? and password=?");
$result->bind_param("ss", $username, $password);
$result->execute();
if($result != false){
$dbArray=$result->fetch();
if(!$dbArray){
echo '<p class="statusmsg">The username or password you entered is incorrect, or you haven\'t yet activated your account. Please try again.</p><br/><input class="submitButton" type="button" value="Retry" onClick="location.href='."'login.php'\">";
return;
}
$_SESSION['username']=$username;
if(isset($_POST['remember'])){
setcookie("jmuser",$username,time()+60*60*24*356);
setcookie("jmpass",$password ,time()+60*60*24*356);
}
redirect();
}
© Stack Overflow or respective owner