I can't seem to get this PHP Login Script to work right. Its not doing what its suppose to be doing. When I type in a Username that is in the Database, it comes up and says: 'Invalid Username or Password'. I can't make sense of it and I don't have enough knowledge yet to know what I'm doing wrong. If someone could help me out that would be great. Thanks guys!
$query = mysql_query("SELECT user_id, username, password, active FROM users WHERE username = '$username' AND password = '$password'") or die('Database Error: ' . mysql_error());
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
The username and password isn't in your users table. This script runs the password through md5(), which is officially cracked so therefore pretty useless.
How did you enter your username/password in your table? Is the password just plain text? If so, that's your problem.
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Try running the query outside the PHP environment, for example using phpMyAdmin and see what you get. When I say run that query, I mean exactly the same query, which means you'll need to assign the query value to a variable, echo it, then copy/paste it and run it in phpMyAdmin. In other words, don't assume anything about the query.