Hey all, I've been having trouble getting a user to be able to 'login' to my site. For some reason, the database is not accepting mysql_num_rows($sql)...
Here's the code I'm using...:
<?php
$sql = "SELECT FROM $TableName WHERE Username='$Array[Username]' AND Password='$Array[Password]'";
function Login ()
{
//the host, user, and pass are stored in the univvars.php file
include ("univvars.php");
$tablename = "test";
mysql_connect($Host, $User, $Pass)
or die("Error");
mysql_select_db($DBName)
or die("Error");
if (mysql_num_rows($sql) == "1")
{
print ("Login successful, redirecting you to main page...");
header ("Location:index.php");
exit;
}
else
{
print ("Login unsuccessful, please enter valid username/password combination!");
exit;
}
}
When the user submits his id and password, a hidden variable was passed along as $submitted. If it existed, then Login() ran. So that's not the problem.
If you can help, thx
I am using PHP4 too, if that makes a difference.