Hello,
I am trying to set a user login that would check a database for existing user and password data. Here is the two scripts I have that should do that, but I keep getting an error no matter what I do.
<html>
<head>
<title>MySQL Login Test</title>
</head>
<body>
</body>
<form action="newlogin.php" method="post">
<p>Name: <input type="txt" value="" name="username" /></p><br />
<p>pass: <input type="txt" value="" name="password" /></p><br />
<p><input type="submit" value="Process →"></p>
</form>
</html>
<?php
if(!$username || !$password)
{
header("Location:newlogin.html");
exit();
}
$user = "user";
$pass = "pass";
$conn=@mysql_connect("localhost", $user, $pass);
if($conn)
{
//echo "Database Connection Successful <br>";
mysql_select_db("weblogin", $conn);
$sql = "select * from 'members' where 'users'=\"$username\" and 'passwords'=\"$password\"";
$rs = mysql_query($sql,$conn);
$match = mysql_numrows($rs);
if($match!=0)
{
header("Location:home.php");
}
mysql_close($conn);
echo "command: $sql <br>";
echo "rs: $rs";
echo "rs1 $rs1";
}
else
{
echo "I die man, i die...<br>";
}
echo "$db_list";
?>
Here is the output:
Warning: mysql_numrows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\newlogin.php on line 22
command: select * from 'members' where 'users'="asfdafd" and 'passwords'="dfasdfasdf"
rs: rs1
Any help would be much appreciated. Thanks in advance!