aarbrouk Posted April 15, 2009 Share Posted April 15, 2009 Hello all, I am new to php I am having trouble loging in after encrypting passwords using md5.... When a customer registers... this is how the values are inserted into the customer table... This successfully encrypts the password into the database $query = "insert into customer values ( '".$USERNAME."' , MD5('".$PASSWORD."'))"; When doing the login check it keeps saying "login failure" when trying to log in using md5... heres the code: <?php session_start(); require "../connect.php"; $username= $_GET['Username']; $password= $_GET['Password']; $query = "select * from customer where Username ='".$username."' and Password=md5('".$password."')"; $result= @mysql_query($query,$connection) or die("Unable to perform query $query".mysql_error()); $row= mysql_fetch_array($result); if ($row != null) { $_SESSION['Username'] = $row['Username']; $_SESSION['FirstName'] = $row['FirstName']; $message ="password correct."; header("Location:../welcome.php?message=$message"); exit(); } else { $message2 ="Invalid username or password, please try again."; header("Location:registrationsignin.php?message=$message2"); exit(); } ?> This problem does not occur when I don't use md5 atall... Can someone tell me how to use the md5 function in the login check script because this is where the problem seems to be Thanks in advance Link to comment https://forums.phpfreaks.com/topic/154256-solved-md5-login-problem/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 15, 2009 Share Posted April 15, 2009 So, is the length of your Password column enough to hold an md5() value? Link to comment https://forums.phpfreaks.com/topic/154256-solved-md5-login-problem/#findComment-810956 Share on other sites More sharing options...
aarbrouk Posted April 15, 2009 Author Share Posted April 15, 2009 Just changed this and it worked so obviously not... thank you very much for your help... Link to comment https://forums.phpfreaks.com/topic/154256-solved-md5-login-problem/#findComment-810961 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.