The last time I posted here I got a lot of help from some guys with a registration system for the MaNGOS database in PHP. Now I have been toying around with a login system.
My problem is that when the script that is being called when logging in, I can't get it to find the password. I think it has something to do with the whole encryption in SHA1. So you guys can get a better insight, I will post the code I have for the login below.
If I haven't expressed my self clearly enough, please let me know and I will post more info about this matter
I really hope you can help me!
Thanks!
Malte
My problem is that when the script that is being called when logging in, I can't get it to find the password. I think it has something to do with the whole encryption in SHA1. So you guys can get a better insight, I will post the code I have for the login below.
PHP:
<?php
$conn = mysql_connect('localhost', 'USERNAME', 'PASSWORD') or die(mysql_error());
mysql_select_db('realmd', $conn); // connecting to database
// Start the session
session_start();
// Check if user wants to login (GET info)
if($_POST['script'] == 'logi'){
// User logs in
If(empty($_POST['account_username']) OR empty($_POST['account_password'])) {
// At least one of the file is empty, display an error
header("Refresh: 0; url=http://127.0.0.1/ll/fields_empty.php");
} else {
// User filled it all in!
// Make variables save with mysql_real_escape_string and md5
$username = mysql_real_escape_string($_POST['account_username']);
$password = mysql_real_escape_string($_POST['account_password']);
// Search for a combination | as you can see here,
//I have changed the password out with email just to check
//if it worked, and so it did. Here is my problem. How do I get
//the SHA1 encrypted password instead of the email?
$query = mysql_query("SELECT id FROM account
WHERE username = '" . $username . "'
AND email = '" . $password . "'
") or die(mysql_error());
// Save result
list($user_id) = mysql_fetch_row($query);
// If the user_id is empty no combination was found
if(empty($user_id)) {
echo 'No combination of username and password found.';
} else {
// the user_id variable doesn't seem to be empty, so a combination was found!
// Create new session, store the user id
$_SESSION['user_id'] = $user_id;
// Redirect to userpanel.php
header('location: about.php');
}
}
}
?>
If I haven't expressed my self clearly enough, please let me know and I will post more info about this matter

I really hope you can help me!
Thanks!
Malte