mySQL troubles..
Posted: Fri Sep 22, 2006 6:21 pm
I have the following code, to try to log a user in, the only problem is everytime it fails and complains about line 13 ($count=mysql_num_rows($result);) Can anyone spot the problem?
Thanks..
Code: Select all
<?php
include("include-mysql.php");
$myusername = $HTTP_POST_VARS['UN'];
$mypassword = $HTTP_POST_VARS['Pass'];
$tbl_name="users"; // Table name
$sql="SELECT * FROM $tbl_name WHERE usr='$myusername' and pass='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
echo "Login Successful!";
}
else {
echo "This login attempt has failed. <br/>Please Check your username and/or password.<br/>";
}
?>