I didn't understand you things completely as you code is more hidden in the pages like includes/dbaccess.php. So i guess like this....
I think if you user require() it won't execute the code inside the page you have specified in that function. Try include() may be that is you mistake.
If this is not the solution please let me know with some more details.
No, the required dbaccess.php is just the database connection script
$link = mysql_connect("IPADDRESS", "USER", "PASSWORD") or die("Could not connect: " . mysql_error());
mysql_select_db("authors") or die("Could not select database");
$result = mysql_query($sql_query) or die("Query failed: " . mysql_error());
Thats all thats there. Include returns the same results. The problem that occurs is that I pull a blank page if a user puts in a username that is not in the database. Other than that, everything works fine!
Where are you checking for that condition in the given code. Your mysql_fetch_array() will not fetch any value if there is no value with this username. You the code inside the while loop won't work. Do a cheking before the while loop.
If the username is not in the database then the result of this query will be empty. So do a checking for this. What you are doing is, is inside the while loop. Which will not work if there is no value for the query result.
Nope, same result...the dbaccess.php pulls $result as the result to the SQL query. I decided to echo $result back to me, to see what it was being fed...
The result was not what I expected, in theory, according to what you said, and what I know, we should have a NULL string, or "" of some sort or fashion. I get "Resource id #2". Now I am just confused.
if ($result == "")
If you check for the condition
This will return a value. If you check for it as true or false... it will be true if the query is executed successfully.
So try fetching the value to a variable and then check if the vairable is empty or not... like :
echo "No user with this userid";
Try fetching the result to another variable instead of $row, for checking false login.
Now do a check for the all the if conditions. Put an echo and mark each the loop so you can get where all your programs goes through.. where is the error can be determined.
One more thing we have to notice is that there would be only one username .. means it would be dstinct. If this is like so then you don't have to use the while loop at all. So where you check for the false login you can do like this
$row = mysql_fetch_array($result);
$dbusername = $row["username"];
$dbpassword = $row["password"];
$dbaccesslevel = $row["access_level"];
if ($dbusername == $username) /// this is also not required, b'coz the rsult wil be of only for the usernae you have asked for.
if ($md5password == $dbpassword)
There are lots of method to do a login check this would be one of them. You can even do this on a sql query itself in stread of doing this in both php and mysql. The script would be little slow than this code
$password = $_REQUEST['password'];
$sql_query = "SELECT username,password,access_level FROM users WHERE username = '$username' and password='$password'";
This will return a row if the username and the username with the supplied password exists in the database.