Hi all, I’ve stumbled over a bug which I’m not sure how to fix. For some reason, my login code is messed up? If I enter the username and password correctly, nothing happens and I log in. Yet if I enter a wrong password, it tells me my password is wrong (like it should) yet changes the database password to something random? So neither what I just typed nor the actual password is correct… any help with this?
here’s the basic login code, without anything sanitized and whatnot:
[code]<?php
if($loggedin == ‘0’)
{
if(isset($_POST[‘submit’]))
{
// Make sure all forms were filled out.
if((!isset($_POST[‘username’])) ||
(!isset($_POST[‘pass’]))
|| ($_POST[‘username’] == ‘’) || ($_POST[‘pass’] == ‘’))
die(“Please fill out the form completely.
Continue”);
// Get user’s record from database
$player = mysql_query(“SELECT * FROM users WHERE username = '”.$_POST[‘username’]."’ AND active IS NULL");
$player = mysql_fetch_assoc($player);
mysql_real_escape_string($username);
mysql_real_escape_string($password);
if($player[‘id’] == false)
die(“Sorry, that user is not in our database or your account isn’t activated.
Back”);
else if($player[‘password’] != md5($_POST[‘pass’]))
die(“Wrong password!
Back”);
$_SESSION[‘id’] = $player[‘id’];
$_SESSION[‘username’] = $player[‘username’];
$_SESSION[‘password’] = $player[‘password’];
$_SESSION[‘callname’] = $player[‘callname’];
$_SESSION[‘email’] = $player[‘email’];
$date = date(“m/d/y”);
$update = @mysql_query(“UPDATE users SET lastlogin = ‘$date’ WHERE id = '”.$_SESSION[‘id’]."’");
echo ‘’;
}
else
{
echo ’