<?php
include("connect.php"); 
$tbl_name="user_levels"; // Table name 

$username=$_POST['username']; // username sent from form 
$password=$_POST['password']; // password sent from form 


// To protect MySQL injection 
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);

//Query
$sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$password'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$rows = mysql_fetch_assoc($result);


//Direct pages with different user levels
if ($rows['userlevel'] == '1') {
	header('location: Verify1.php'); //User1 
	session_register("username");
	session_register("password");
	
}
else
if ($rows['userlevel'] == '2') {
	header('location: Verify2.php'); //User2 
	session_register("username");
	session_register("password"); 
	
} 
else
if ($rows['userlevel'] == '3') {
	header('location: Verify3.php'); //user 3 
	session_register("username");
	session_register("password"); 

} 
else
if ($rows['userlevel'] == '4') {
	header('location: Verify4.php'); // user4 
	session_register("username");
	session_register("password");
	
} 
else
if ($rows['userlevel'] == '5') {
	header('location: Verify5.php'); // user5 
	session_register("username");
	session_register("password");
	
} 
else
if ($rows['userlevel'] == '6') {
	header('location: Verify6.php'); // user6 
	session_register("username");
	session_register("password"); 
	
} 
else
if ($rows['userlevel'] == '7') {
	header('location: Verify7.php'); // user7 
	session_register("username");
	session_register("password"); 
	
} 
else
if ($rows['userlevel'] == '8') {
	header('location: Verify8.php'); // user8 
	session_register("username");
	session_register("password"); 
	
}
else
if ($rows['userlevel'] == '9') {
	header('location: Verify9.php'); // user9 
	session_register("username");
	session_register("password"); 
	
}
else
if ($rows['userlevel'] == '10') {
	header('location: Verify10.php'); // user10 
	session_register("username");
	session_register("password"); 
	
}
else
if ($rows['userlevel'] == '11') {
	header('location: Verify11.php'); // user11 
	session_register("username");
	session_register("password"); 
	
}
else
if ($rows['userlevel'] == '12') {
	header('location: Verify12.php'); // user12 
	session_register("username");
	session_register("password"); 
	
}
else
if ($rows['userlevel'] == '13') {
	header('location: Verify13.php'); // user13 
	session_register("username");
	session_register("password"); 
	
}
else
if ($rows['userlevel'] == '14') {
	header('location: Verify14.php'); // user14 
	session_register("username");
	session_register("password"); 
	
}
else
if ($rows['userlevel'] == '15') {
	header('location: Verify15.php'); // user15 
	session_register("username");
	session_register("password"); 
	
}
else
if ($rows['userlevel'] == '16') {
	header('location: Verify16.php'); // user16 
	session_register("username");
	session_register("password"); 
	
}
else
if ($rows['userlevel'] == '17') {
	header('location: Verify17.php'); // user17 
	session_register("username");
	session_register("password"); 
	
}
else
if ($rows['userlevel'] == '18') {
	header('location: Verify18.php'); // user18 
	session_register("username");
	session_register("password"); 
	
} 
else
{ 
	// Error login
echo "<script>alert('Access Denied!');
						window.location='index.php';
						</script>";
}

?>