i am trying to create a login page so the staff will be directed to one place while the students will be directed to another. this code is still in the making hence no location function was included as yet. can any one help me with this code please

<?php
$host="localhost"; // Host name 
$username="root"; // Mysql username 
$password="hayden"; // Mysql password 
$db_name="ecng3020"; // Database name 
$tbl_name="students"; // Table name
$tbl_name_1="staff"; // Table name

// Connect to server and select databse.
$con=mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// username and password that was sent from the form
$username=$_POST['username_1']; 
$password=$_POST['password_1'];



md5($password);
//students querry 
$sql="SELECT * FROM $tbl_name WHERE id_no='80600016' and password='806000169'";

//staff querry
$sql_1="SELECT * FROM $tbl_name_1 WHERE first_name='$username' and password='$password'";
//

if ($password!='' && $password!='')
{
	$sql="SELECT * FROM $tbl_name WHERE id_no='80600016' and password='806000169'";
	if(mysql_num_rows($sql,$con) == 1)
	{
		$result=mysql_query($sql);
		while ($row = mysql_fetch_row($result))
		$user=$row[0];
		$pass=$row[4];
			if($user==$username && $pass==$password )
			{
				echo "getting there student";
			}
			else
			{
				echo"wrong username and password";
			}	
	}
}	
else
	if(mysql_num_rows($sql_1) == 1)
	{
		$result_1=mysql_query($sql_1);
		while ($row_1 = mysql_fetch_row($result_1,$con))
		$user_1=$row_1[2];
		$pass_1=$row_1[3];
			if($user_1==$username&& $pass_1==$password)
			{
				echo "getting there staff";
			}
			else
			{
				echo"wrong username and password";
			}		
	}
}
?>

i am trying to create a login page so the staff will be directed to one place while the students will be directed to another. this code is still in the making hence no location function was included as yet. can any one help me with this code please

Hey, your username is similar to mine. Was that deliberate lol. Anyways is this a code snippet for the gallery or is it a problem you want others to help solve. If it is a problem you want others to help solve then I would suggest telling the moderators that this is not a code snippet but instead a forum thread. That can be done with the flag bad post button.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.