<?PHP 

include("database.php");

$user_name = $_POST['username'];

$password = $_POST['password'];   

$result=mysql_query("select * from login where username='$user_name' AND password='$password'"); 

$rowCheck = mysql_num_rows($result); 



	if($rowCheck > 0)

	{  

		 $login="success";

		 session_start();

		 $_SESSION['username']=$user_name;

		 $_SESSION['password']= $password;

		 $row = mysql_fetch_row($result); 

		 $_SESSION['userid']=$row[0];

		 $_SESSION['cat']=$row[8];

		 if($_SESSION['cat']=='admin')

		 {

			 //$_SESSION['admin']=$username;

			// include("log.php");

	?>

			<script language="javascript" type="text/javascript">

			window.location="index_grid.php"

			</script>

	<?php

		 }

		 if($_SESSION['cat']=='superadmin')

		 {

			 //$_SESSION['manager']=$username;

	?>

			<script language="javascript" type="text/javascript">

			window.location="super_admin_grid.php"

			</script>

	<?php

		 }

		 if($_SESSION['cat']=='user')

		 {

			 //$_SESSION['client']=$username;

			 echo $_SESSION['cat'];

	?>

			<script language="javascript" type="text/javascript">

			window.location="index_grid.php"

			</script>

	<?php

		 }

	}

    else

	{

	 	$login="fail";

	?>

		<script language="javascript" type="text/javascript">

        alert("Enter Correct Username And Password");

        window.location="../index.php"

        </script>

	<?php

	}                                    

?>