Here is my login process file -
<?php
require_once("db/connect.php");
session_start();
//Field Data
if (isset($_POST['username'], $_POST['password'], $_POST['Submit'])){
$username = $_POST['username'];
$password = md5($_POST['password']);
$submitted = $_POST['Submit'];
if ($username && $password){
//////////////////////////////////////////////////
$query = sprintf("SELECT * FROM users WHERE username='%s' AND password='%s'",$username,$password);
$result = mysql_query($query);
$rowAccount = mysql_fetch_array($result);
//////////////////////////////////////////////////
if ($rowAccount){
$_SESSION['id'] = $rowAccount['username'];
header("Location:user_area/");
exit;
} else {
echo "You have entered the wrong username or password";
}
}
else
{
echo "You have not filled in all the fields";
}
}
?>
And now here is my register process file -
<?php
require_once("db/connect.php");
session_start();
//Declare Variables
$Username = $_POST['username'];
$Email = $_POST['email'];
$Email1 = "@";
$Email_Check = strpos($Email,$Email1);
$Password = md5($_POST['password']);
$Re_Password = md5($_POST['re-password']);
//Check To See If All Information Is Correct
if($Username == "")
{
die("Opps! You don't enter a username!");
}
if($Password == "" || $Re_Password == "")
{
die("Opps! You didn't enter one of your passwords!");
}
if($Password != $Re_Password)
{
die("Ouch! Your passwords don't match! Try again.");
}
if($Email_Check === false)
{
die("Opps! That's not an email!");
}
//Insert Into Database
if(!mysql_query("INSERT INTO users (email, username, password)
VALUES ('$Email', '$Username', '$Password')"))
{
die("We could not register you due to a error (Contact the website owner if this continues to happen.)");
}else{
die("User Created");
}
?>
Now when a user registers the password becomes encrypted in the database but then when a user goes to login through login process file the users password does not become encrypted so it does match the password in the database so if shows the message -
You have entered the wrong username or password
echo "You have entered the wrong username or password";
How would i get it so the password that the user has entered in the login form becomes encrypted so it matches the password in the database so the user can login.