Jump to content

[SOLVED] md5 login problem


aarbrouk

Recommended Posts

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

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.