So I started writing a test page to get the hang of querying the database. I finnally got it to work. However, If I try and enter a username that I know is not in the database, it won't print the output saying that the user is in the database.
It will output if the user is in the database, but not the oposite. Can someone help me out here?
Here is the code...
Code: Select all
$username=$_POST['u_name'];
$db=mysql_connect("localhost","****","*******") or die (mysql_error());
mysql_select_db("myforum",$db) or die ('Cannot select database : ' . mysql_error());
$query=mysql_query("SELECT * FROM ibf_members WHERE name='$username'");
if (!$query) {
die ('Invalid query : ' . mysql_error());
}
while ($db_name=mysql_fetch_array($query)) {
if ($username == $db_name[name]) {
print "It works! $username is in the database!";
}
else {
print "$username is not in the database";
}
}
mysql_close();