login problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
picasso
Forum Newbie
Posts: 5
Joined: Mon Feb 23, 2004 8:39 am

login problem

Post 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;
?>
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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 ;)
Post Reply