
<?php
$Username = $_POST["Username"];
$Password = $_POST["Password"];
$a = $_POST['a'];

//echo $admin." ".$password;
	$login=mysql_connect('localhost', 'wauhaha_karaoke', 'cross123','wauhaha_karaoke');
	
	mysql_selectDB("wauhaha_karaoke",$login);

$result = mysql_query("select * from admin where Username='$Username' and Password='$Password'");
$result2= mysql_query("select * from staff where Username='$Username' and Password='$Password'");

$login_success="You have login successfully. The browser will automatically redirect you into the system.";


if($a == "Admin"){
if(mysql_num_rows($result)>0){
			echo "<meta http-equiv=refresh content=5;url=http://www.wauhaha.com/karaoke/adminaccount.php?user=$Username>";
			echo "<body style=font-family:verdana;color:white   bgcolor=black>";
            echo "<table border=1 rules=none bordercolor=lightblue width=70% align=center style='font-family:verdana;font-size:8pt'>";
            echo "<tr valign=middle><th colspan=2 bgcolor=lightblue align=center>LOGIN SUCCESSFUL</th></tr>";
            echo "<tr><td>$login_success</td></tr>";
            echo "<tr><td><a href=http://www.wauhaha.com/karaoke/adminaccount.php?user=$Username><b style=color:white>Please click here if the browser does not automatically redirect.<b></a></td></tr>";
            echo "</table>";
			echo "</body>";die;
			
			}else
            echo "<meta http-equiv=refresh content=5;url=index.php>";
			echo "<body  bgcolor:black style=font-family:verdana;color:white>";
            echo "<script>alert('Please Re-enter Your Username and Password.')</script>";
			echo "<script language='javascript'>window.location='http://www.wauhaha.com/karaoke/index.php'</script>";	
            echo "<tr><td><a href=http://www.wauhaha.com/karaoke/K_Login.php><b style=color:white>Please click here if the browser does not automatically redirect.</b></a></td></tr>";
            echo "</table>";
			echo "</body>";die;
	
	}
		
		
		if($a =="Staff"){
		if(mysql_num_rows($result2)>0){
		$row = mysql_fetch_array($result2);
		$StaffID = $row['StaffID'];
			echo "<meta http-equiv=refresh content=5;url=http://www.wauhaha.com/karaoke/staffaccount.php?StaffID=$StaffID>";
			echo "<body  bgcolor=black style=font-family:verdana;color:white>";
            echo "<table border=1 rules=none bordercolor=lightblue width=70% align=center style='font-family:verdana;font-size:8pt'>";
            echo "<tr valign=middle><th colspan=2 bgcolor=lightblue align=left>LOGIN SUCCESSFUL</th></tr>";
            echo "<tr><td>$login_success</td></tr>";
            echo "<tr><td><a href=http://www.wauhaha.com/karaoke/staffaccount.php?StaffID=$StaffID><b style=color:white>Please click here if the browser does not automatically redirect.</b></a></td></tr>";
            echo "</table>";
			echo "</body>";die;
		}else
            echo "<meta http-equiv=refresh content=5;url=index.php>";
			echo "<body  bgcolor:black style=font-family:verdana;color:white>";
            echo "<script>alert('Please Re-enter Your Username and Password.')</script>";
			echo "<script language='javascript'>window.location='http://www.wauhaha.com/karaoke/index.php'</script>";	
            echo "<tr><td><a href=http://www.wauhaha.com/karaoke/K_Login.php><b style=color:white>Please click here if the browser does not automatically redirect.</b></a></td></tr>";
            echo "</table>";
			echo "</body>";die;

		
		}
		
		
		if($a == "Kitchen"){
		if(mysql_num_rows($result2)>0){
		$row = mysql_fetch_array($result2);
		$StaffID = $row['StaffID'];
			echo "<meta http-equiv=refresh content=5;url=http://www.wauhaha.com/karaoke/kit_staffaccount.php?StaffID=$StaffID>";
            echo "<body  bgcolor=black style=font-family:verdana;color:white>";
			echo "<table border=1 rules=none bordercolor=lightblue width=70% align=center style='font-family:verdana;font-size:8pt'>	";
            echo "<tr valign=middle><th colspan=2 bgcolor=lightblue align=left>LOGIN SUCCESSFUL</th></tr>";
            echo "<tr><td>$login_success</td></tr>";
            echo "<tr><td><a href=http://www.wauhaha.com/karaoke/kit_staffaccount.php?StaffID=$StaffID><b style=color:white>Please click here if the browser does not automatically redirect.</b></a></td></tr>";
            echo "</table>";
			echo "</body>";die;
		}else
            echo "<meta http-equiv=refresh content=5;url=index.php>";
			echo "<body  bgcolor:black style=font-family:verdana;color:white>";
            echo "<script>alert('Please Re-enter Your Username and Password.')</script>";
			echo "<script language='javascript'>window.location='http://www.wauhaha.com/karaoke/index.php'</script>";	
            echo "<tr><td><a href=http://www.wauhaha.com/karaoke/K_Login.php><b style=color:white>Please click here if the browser does not automatically redirect.</b></a></td></tr>";
            echo "</table>";
			echo "</body>";die;

		
		
		}
		
?>
