Can't get passed this if statement. Why??? can you help?
Posted: Fri May 11, 2007 1:03 pm
Hi,
I'm new to PHP. I am having real problems getting passed this if statement. I'm sure the answer is staring me in the face.
I think it is a problem with the mysql_query line. The if statement below keeps showing true.
Any Ideas???
Thanks in advance
Toby
-----------------------------
Weirdan| Fixed broken syntax tags
I'm new to PHP. I am having real problems getting passed this if statement. I'm sure the answer is staring me in the face.
I think it is a problem with the mysql_query line. The if statement below keeps showing true.
Any Ideas???
Thanks in advance
Toby
-----------------------------
Code: Select all
<?php
session_start();
$links = "<a herf = 'main.php'> Click here to go back to the main page.</a><br><br><a herf = 'logout.php'> Click here to logout.</a>";
if ($loginid && $password) {
if ($logged_in_user == $loginid)
echo $loginid.", you are already logged in.<br>";
echo $links;
exit;
}
$db = mysql_connect('xxxxxxxxxxx', 'xxxxxxxxxxx', 'xxxxxxxxxxxxxx');
$result = mysql_query("SELECT * FROM members WHERE loginid = '".$loginid."'
AND password = '".$password."'");
if (!$result) {
echo "Sorry, we are having technical diffuculties. We cannot enter your details."; //<--- This line keeps showing true//
exit;
}
if (mysql_num_rows($result) >0){
$logged_in_user = $loginid;
session_register("logged_in_user");
echo "<h1>Welcome '".logged_in_user."'</h1><br><br>$links";
exit;
}
else{
echo "There is no match on our records. Please try again or register as a new user";
}
?>