if ($user_id == "") {
print "We're sorry, your username does not appear to be in our database.";
}
else {
// End of Check Username
// query and other commands
$resultID = mysql_query("SELECT user_password FROM phpbb_users WHERE username = '$username'", $linkID) or die(mysql_error());
$encryptedpassword = md5($password);
$row = mysql_fetch_array($resultID);
$passwordfromdb = $row[0];
// End of query commands
// Check Password
if ($encryptedpassword == $passwordfromdb) {
print "We're sorry, your password or username is incorrect.";
}
else {
print "login currect";
}
}
// End of Check Password
mysql_close($linkID);
?>
I'm sure it's something so simple but I can't seem to find it.
Thanks.
From a first look, your code looks well done and should work alright. From the output it generates, you know already that the problem must lie somewhere in these lines:
Which further indicates, that there is either no appropriate data in the database or the query was somehow malformed. I would suggest narrowing the problem by trying to run this adjusted code:
PHP Code:
mysql_select_db("phpbb2", $linkID) or die(mysql_error());
$sql = "SELECT user_id FROM phpbb_users WHERE username = '$username'";
// trace the contents of $sql
echo $sql . "<br>";
$resultID = mysql_query($sql, $linkID) or die(mysql_error());
This should show you what your query acutally consisted of. Also, all returned values from the query will be shown. Perhaps it's just a typo, but I could also think that you're expecting form variables to extracted automagically by the register_globals option. In modern versions of PHP, this feature is disabled by default. Maybe your provider did an upgrade and failed to inform you. In this case, you could try with
$_POST["username"]
to get the values of the form variable instead of just writing $username.
okay, thanks but I found my problem after trying some more test.
I had a file (mysql.inc) with $username and $password varable in it for the MySQL username and password, so I changed it's name and it works.. kinda..
Now even if I don't put a password in it logs in.
As you can see I'm trying to use a PHPBB database, and it should work, but it's not checking password.
here's the code (same as before):
PHP Code:
<?php
// MySQL User Login, Copyright 2002 Acorn Webs. All Rights Reserved.
//
// This Script is for Acorn Webs use ONLY!
// Includes Acorn Webs Clients.
// Include Files
require("includes/mysql.inc");
// End of Include Files
// query commands
mysql_select_db("phpbb2", $linkID) or die(mysql_error());
$resultID = mysql_query("SELECT user_id FROM phpbb_users WHERE username = '$username'", $linkID) or die(mysql_error());
I put !== back, then I decided to check my form.. and I had the password feild wrong!... gosh
Sorry to wast anyones time.. seems my code was fine all the way.. all but my stupid form.
Lol.. I made my post about same time you made yours... and was no problem I enjoyed working around with it anyways... I am finally learning some MySQL stuff and more PHP
Yeah, MySQL isn't hard to learn. PHP is prety simple too.
Thanks once again for you time messing with my junk codin
If you ever need anything just ask.. (I might help )
(I sell hosting )