Page 1 of 1

login problem

Posted: Fri Mar 19, 2004 12:36 am
by picasso
When the the password is enter correctly, it will direct to query2 page. What i wanted was that when either the staff or student enter their password correctly, it will direct to the suppose pages.Whats went wrong to my script? Could someone help me?

Code: Select all

<?
$uid=$userid;
$pwd=$userpassword;
$db=mysql_connect("localhost","@@","@@");
mysql_select_db("user");
$query1="select * from staff where userid='$userid' and userpassword='$userpassword'";

$result1=mysql_query($query1);
$numrows=mysql_num_rows($result1);
if($numrows1>0)
&#123;
	echo "<meta http-equiv='refresh' content='0;URL=search2.htm'>";
&#125;
else
&#123;
	echo "<b>Login failed. Please try again<br>";
	echo "<a href='login.htm'>Back To Login Page</a>";
&#125;

$query2="select * from student where userid='$userid' and userpassword='$userpassword'";
$result2=mysql_query($query2);
$numrows2=mysql_num_rows($result2);
if($numrows2>0)
&#123;
	echo "<meta http-equiv='refresh' content='0;URL=view2.php'>";
&#125;
else
&#123;
	echo "<b>Login failed. Please try again<br>";
	echo "<a href='login.htm'>Back To Login Page</a>";
&#125;
?>

Posted: Fri Mar 19, 2004 12:41 am
by markl999
$numrows=mysql_num_rows($result1);
if($numrows1>0)
Shouldn't that be $numrows1=mysql_num_rows($result1); ?

And you say the script doesn't work, how exactly isn't it working? .. might help narrow down where the problem is ;)