Jump to content

*RESOLVED* Login with md5 encryption


JJohnsenDK

Recommended Posts

Hey

Im trying to make a login system. I encrypt the password into MySql database with the md5() function, that works just great. But how do i turn the encryption around and unencrypt the password when the user needs to login?

At the moment i'm using this code. I might be totally off course, but here it is:

[code]if(isset($_POST['submit'])){
if( empty($_POST['uname']) && (empty($_POST['upass']))){
header( "Location:Messages.php?msg=1" );
exit();
}

$_POST['upass'] = md5($_POST['upass']);

//Connecter til MySql Databasen.
include('config.php');
$query="select * from user where uname='".$_POST['uname']."'  and pw='".$_POST['upass']."' ";
$result=mysql_query($query);

$num=mysql_num_rows($result);
if($num>0 ){

//Laver sessions om til variabler
$mytime=time();
$mytime=date("H:i:s A",$mytime);
$_SESSION['time'] = $mytime;
$_SESSION['status'] = 'logged';
$_SESSION['username'] = $n;
//Sender brugeren videre til welcome.php hvis bruger og pass er rigtig
header("location:welcome.php");
exit;
}else{
$_SESSION['status'] = 'not logged';
header( "Location:Messages.php?msg=2" );
exit();
}
}[/code]

Im using this line $_POST['upass'] = md5($_POST['upass']); to unencrypt the password, but it doesnt work so its propperly not right. Anyone who can figure out what i should use insted?
Link to comment
https://forums.phpfreaks.com/topic/27603-resolved-login-with-md5-encryption/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.