25.09.2013, 17:33
Hi, i am editing one UCP but i cant login with the password which i am registering from IG.
I am hashing my passwords with md5 and i can only login with the hashed password so i tryed a way to hash the password which player enters when he wants to login with the password which is already hashed in the database, but i cant get it to work
Can any PHP expert help me solve this problem?
I am hashing my passwords with md5 and i can only login with the hashed password so i tryed a way to hash the password which player enters when he wants to login with the password which is already hashed in the database, but i cant get it to work
Can any PHP expert help me solve this problem?
PHP код:
$submit = $_POST['submit'];
$logout = $_POST['logout'];
$username = sanitize($_POST['Name']);
$password = sanitize($_POST['Password']);
$rawInput = sanitize($_POST["password"]);
$hashedInput = hash("md5", $rawInput);
if($submit)
{
if(!strcmp($password, $hashedInput))
{
if($username && $password)
{
$query = mysql_query("SELECT * FROM `players` WHERE `Name` = '$username' AND `Password` = '$password'");
if(mysql_num_rows($query) == 1)
{
while($row = mysql_fetch_assoc($query))
{
$dbusername = $row['Name'];
$dbpassword = $row['Password'];
}
if($username == $dbusername && $password == $dbpassword)
{
setcookie("Name", $dbusername, time()+60*60*24*365*20);
$_SESSION['Name'] = $dbusername;
header('Location: index.php');
}
else echo "<script>alert('You have to enter password!');</script>";
}
}
}
}