<?php 
session_start();
$email= $_POST['email'];
$password= $_POST['password'];

$email= stripcslashes($email);
$password= stripcslashes($password);
$email= mysql_real_escape_string($email);
$password= mysql_real_escape_string($password);


mysql_connect("localhost","root","");
mysql_select_db("login");

$result = mysql_query("select * from   tbl_users  where email= '$email' and password= '$password'") or die ("failed to query database" .mysql_error());

$row = mysql_fetch_array($result);


if($row['email']==$email  && $row['password'] == $password)
{
	
	$_SESSION['email']= $row['email'];
echo ("<SCRIPT LANGUAGE='JavaScript'>
 
    window.location.href='index.php';
    </SCRIPT>");
	
}
else{
	echo ("<SCRIPT LANGUAGE='JavaScript'>
    window.alert('Login unsuccessful Please Try Again')
    window.location.href='main.php';
</SCRIPT>");}


?>
