Jump to content

LogIn Not Working


pudge1

Recommended Posts

For some reason my LogIn script doesn't work. It connects to the database and everything alright but it doesn't work at all. I've checked the database multiple time and the information I am inputting IS in there.

 

  function Login($username,$password)
    {
    $user = '***';
    $pass = '***';
    $dbname = '***';

    $connection = mysql_connect('localhost',$user,$pass);
    mysql_select_db($dbname, $connection);

    $sql = "SELECT Password FROM Users WHERE Username='$username'";
    $query = mysql_query($sql , $connection);

    $arr = mysql_fetch_array($query);

    $a_password = $arr["Password"];

     if($password == $a_password)
      {
       setcookie('LOGGED_IN','True_',time()+172800);
       setcookie('USERNAME',$username,time()+172800);
      }
     else
      {
      }
    }

 

That is the function here it is in use:

 

$username = mysql_real_escape_string( $_POST['username'] );
$password = mysql_real_escape_string( $_POST['password'] );

$username = strtolower($username);
$password = strtolower($password);

$username = md5($username);
$password = md5($password);

Login($username,$password);

Link to comment
https://forums.phpfreaks.com/topic/209815-login-not-working/
Share on other sites

Send the query and the resulting array to the screen and see what you get.

 

$sql = "SELECT Password FROM Users WHERE Username='$username'";
$query = mysql_query($sql , $connection);
$arr = mysql_fetch_array($query);

echo $sql . '<br /><pre>';
print_r($arr);
echo '</pre>';

Link to comment
https://forums.phpfreaks.com/topic/209815-login-not-working/#findComment-1095360
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.