<?php 
session_start();
ob_start();
include_once("dbconnect.php");
if($_POST['uname']!="" && $_POST['pass']!="")
{
	
$res=mysql_query("select * from register where Email='".$_POST['uname']."' and Password='".$_POST['pass']."' ");

if(!$loginval=mysql_fetch_array($res))
 {
	 $_SESSION['error']="You Are Not Valid User";
 header("Location: login.php");
 }
 else
 {
 $_SESSION['idluser']=$_POST['uname'];
 
 $_SESSION['userid']=$loginval['user_id'];

  if($_SESSION['idlcount']>0 && isset($_SESSION['idlcount']))
    {
	
			header("Location: shoppingcart.php");
		
	}
	else if($_SESSION['url']=="")
	{
	
	header("Location: index.php");
	}else if($_SESSION['url']!=""){
		header("Location:".$_SESSION['url']);
	}
 }
}
else if($_POST['uname']!="" && $_POST['pass']=="")
{
	$_SESSION['error']="Please Enter Password";
		header("Location: login.php");

}
else if($_POST['uname']=="" && $_POST['pass']!="")
{
	$_SESSION['error']="Please Enter Username";
	header("Location: login.php");
}
else if($_POST['uname']=="" && $_POST['pass']=="")
{
	
	$_SESSION['error']="Please Enter Password and Username";
	header("Location: login.php");

}

?>