
<?php
include("sess_page.php");
include("include/dbconnect.php");
require_once("email.php");
extract($_POST);
$msg="";
if(isset($login))
{
 if(trim($uname=="")) { $msg = "Enter the Username"; }
 else if(trim($pwd=="")) { $msg = "Enter the Password"; }
	else
	{
		if($uname=="admin")
		{
		$safe_variable = mysql_real_escape_string("admin");
			if($safe_variable=="admin")
			{
			
			$qry = "select * from admin where username='$uname' && password='".$pwd."'";
			$exe=mysql_query($qry);
			$row=mysql_fetch_array($exe);
			$email=$row['email'];
			$num=mysql_num_rows($exe);
				if($num==1)
				{
				$_SESSION['uname']=$uname;
					
				header("location:admin.php");
				}
				else
				{
				$msg="Login Incorrect!";
				}
			}
			else
			{
			print "<script type=\"text/javascript\">"; 
			print "alert('SQL INJECTION WARNING ACCESS DENIED')";
			print "</script>";  
			}
		}
		else
		{
			$safe_variable = mysql_real_escape_string($uname);
			if($safe_variable==$uname)
			{
			$qry = "select * from register where username='$uname' && password='".$pwd."'";
			$exe=mysql_query($qry);
			$row=mysql_fetch_array($exe);
			$num=mysql_num_rows($exe);
					if($num==1)
					{
				$pur_qry=mysql_query("select max(pid) from user_purchase");
				$pur_max=mysql_fetch_array($pur_qry);
				$pm_row=$pur_max['max(pid)']+1;
				$_SESSION['purchase_id']=$pm_row;
				
					$_SESSION['uname']=$uname;
					header("location:user_page.php");
					}
					else
					{
					$msg="Login Incorrect!";
					}
				
			}
			else
			{
			print "<script type=\"text/javascript\">"; 
			print "alert('SQL INJECTION WARNING ACCESS DENIED')";
			print "</script>"; 
			}
		}
	}
	
}//login


?>

<!DOCTYPE html>
<html lang="en">
<head>
	<title>FakeReview</title>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
<!--===============================================================================================-->	
	<link rel="icon" type="image/png" href="images1/icons/favicon.ico"/>
<!--===============================================================================================-->
	<link rel="stylesheet" type="text/css" href="vendor1/bootstrap/css/bootstrap.min.css">
<!--===============================================================================================-->
	<link rel="stylesheet" type="text/css" href="fonts1/font-awesome-4.7.0/css/font-awesome.min.css">
<!--===============================================================================================-->
	<link rel="stylesheet" type="text/css" href="vendor1/animate/animate.css">
<!--===============================================================================================-->	
	<link rel="stylesheet" type="text/css" href="vendor1/css-hamburgers/hamburgers.min.css">
<!--===============================================================================================-->
	<link rel="stylesheet" type="text/css" href="vendor1/select2/select2.min.css">
<!--===============================================================================================-->
	<link rel="stylesheet" type="text/css" href="css1/util.css">
	<link rel="stylesheet" type="text/css" href="css1/main.css">
<!--===============================================================================================-->
<script language="javascript">
function validate()
{
	if(document.form1.uname.value=="")
	{
	alert("Enter the Username");
	document.form1.uname.focus();
	return false;
	}
	if(document.form1.pwd.value=="")
	{
	alert("Enter the Password");
	document.form1.pwd.focus();
	return false;
	}

return true;
}
</script>


</head>
<body>
	
	<div class="limiter">
		<div class="container-login100">
			<div class="wrap-login100">
				<div class="login100-pic js-tilt" data-tilt>
					<img src="images1/img-01.png" alt="IMG">
				</div>

<form id="form1" name="form1" method="post" action="" class="login100-form validate-form>
					<span class="login100-form-title">
						<h2>Member Login</h2>
					</span>
<p>&nbsp;</p>
					<div class="wrap-input100 validate-input" data-validate = "Valid email is required: ex@abc.xyz">
						
						  <input type="text" class="input100" name="uname" placeholder="Your Name" required data-error="Please enter your name">
						<span class="focus-input100"></span>
						<span class="symbol-input100">
							<i class="fa fa-user" aria-hidden="true"></i>
						</span>
					</div>

					<div class="wrap-input100 validate-input" data-validate = "Password is required">
						
						 <input type="password" placeholder="Your Password"  class="input100" name="pwd" required data-error="Please enter your password">
						<span class="focus-input100"></span>
						<span class="symbol-input100">
							<i class="fa fa-lock" aria-hidden="true"></i>
						</span>
					</div>
					
					<div class="container-login100-form-btn">
						<input class="login100-form-btn" value="Login" onClick="return validate()" type="submit" name="login" />
						
					</div>

					

					
				</form>
			</div>
		</div>
	</div>
	
	

	
<!--===============================================================================================-->	
	<script src="vendor1/jquery/jquery-3.2.1.min.js"></script>
<!--===============================================================================================-->
	<script src="vendor1/bootstrap/js/popper.js"></script>
	<script src="vendor1/bootstrap/js/bootstrap.min.js"></script>
<!--===============================================================================================-->
	<script src="vendor1/select2/select2.min.js"></script>
<!--===============================================================================================-->
	<script src="vendor1/tilt/tilt.jquery.min.js"></script>
	<script >
		$('.js-tilt').tilt({
			scale: 1.1
		})
	</script>
<!--===============================================================================================-->
	<script src="js1/main.js"></script>

</body>
</html>