hi, i have a problem in login form, whene i try to see if it works, but there is an error,
so hope if you can help me and thx ;)
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\test\login.php on line 11
Username or password
<?php
if(isset($_POST['user']))
{
$user = $_POST['user'];
$pass= md5 ($_POST['pass']);
$con = mysql_connect("localhost", "root", "");
if(!$con){die('could not connect: '.mysql_ereor());}
mysql_select_db("test", $con);
if(mysql_num_rows(mysql_query("SELECT * FROM users where username='$user' AND password='$pass' ")))
{
$result = mysql_query("SELECT * FROM users WHERE username = '$user' AND password = '$pass'");
while($row = mysql_fetch_array($result))
{
$expire = time()+60*60*24*30;
setcookie("uid", $row['uid'], $expire);
echo "Logged in. as <b>".$row['username']."</b>";
}
}else{
echo"<b>Username or password</b><br><br>";
}
mysql_close($con);
}
echo "<form method='post'>
Username:<input type='text' name='user'><br>
Password:<input type='password' name='pass'><br>
<input type='submit' value='LOG IN'>
</form>";
?>