<?php
	session_start()
	
?>
<?php
	include'connection.php';
	ob_start();
	if(isset($_POST['login']))
	{
		$username=$_POST['uname'];
		$password=$_POST['upass'];
		$remember=$_POST['remember'];
		$sub=substr($username,"0","2");
		if($sub==11)
		{
			$query="select * from admin where Userid='$username' and Password='$password'";
			$run=mysqli_query($con,$query);
			$row=mysqli_num_rows($run);
			if($row<1)
			{
				echo "<center><h3 style='color:red; background:white; padding:10px'>User Id Or Password Does Not Correct !</h3></center>";
			}
			else
			{
			    
				$data=mysqli_fetch_assoc($run);
				$id=$data['Userid'];
			    if(empty($remember))
			    {
			        if(isset($_COOKIE["member_name"]))
			        {
			        setcookie ("member_name","");
			        }
			        if(isset($_COOKIE["member_pwd"]))
			        {
			         setcookie ("member_pwd", "");
			        }
			        $_SESSION['adm']=$id;
				    header('location:Admin/admin.php');
			    }
			    else
			    {   
			        setcookie ("member_name",$username, time()+(86400*30));
			        setcookie ("member_pwd", $password, time()+(86400*30));
			        $_SESSION['adm']=$id;
				    header('location:Admin/admin.php');
			    }
	
				
			}
		}
		elseif($sub==22)
		{
		    $query="select * from admin where Userid='$username' and Password='$password'";
			$run=mysqli_query($con,$query);
			$row=mysqli_num_rows($run);
			if($row<1)
			{
				echo "<center><h3 style='color:red; background:white; padding:10px'>User Id Or Password Does Not Correct !</h3></center>";
			}
			else
			{
			    $query1="select * from admin where Userid='$username' and Password='$password' and Active=0";
				$run1=mysqli_query($con,$query1);
				$row1=mysqli_num_rows($run1);
				if($row1<1)
				{
				    echo "<center><h3 style='color:red; background:white; padding:10px' >User Id Does Not Active !</h3></center>";
				}
				else
				{
    				$data=mysqli_fetch_assoc($run);
	    			$id=$data['Userid'];
	                
    			    if(empty($remember))
	    		    {
		    	        if(isset($_COOKIE["member_name"]))
			            {
			                setcookie ("member_name","");
    			        }
	       		        if(isset($_COOKIE["member_pwd"]))
		    	        {
			                 setcookie ("member_pwd", "");
			            }
    			        $_SESSION['subadm']=$id;
		    	    	header('location:SubAdmin/SubAdmin.php');
		    	    }
			        else
			        {   
    			        setcookie ("member_name",$username, time()+(86400*30));
	    		        setcookie ("member_pwd", $password, time()+(86400*30));
		    	        $_SESSION['subadm']=$id;
			        	header('location:SubAdmin/SubAdmin.php');
			        }
		    		
				}
			}
		}
		elseif($sub==50)
		{
			$query1="select * from retailer where Userid='$username'";
			$run1=mysqli_query($con,$query1);
			$row1=mysqli_num_rows($run1);
			if($row1<1)
			{
			    echo "<center><h3 style='color:red; background:white; padding:10px'>User Id Does Not Correct !</h3></center>";
			}
			else
			{
				$query="select * from retailer where Userid='$username' and Password='$password'";
				$run=mysqli_query($con,$query);
				$row=mysqli_num_rows($run);
				if($row<1)
				{
					echo "<center><h3 style='color:red; background:white; padding:10px'>Password Does Not Correct !</h3></center>";
				}
				else
				{
					$query1="select * from retailer where Userid='$username' and Password='$password' and Active=0";
					$run1=mysqli_query($con,$query1);
					$row1=mysqli_num_rows($run1);
					if($row1<1)
					{
						echo "<center><h3 style='color:red; background:white; padding:10px' >User Id Does Not Active !</h3></center>";
					}
					else
					{
						$data=mysqli_fetch_assoc($run1);
						$id=$data['Userid'];
			            
        			    if(empty($remember))
	        		    {
		        	        if(isset($_COOKIE["member_name"]))
			                {
			                    setcookie ("member_name","");
    			            }
	       		            if(isset($_COOKIE["member_pwd"]))
    		    	        {
	    		                 setcookie ("member_pwd", "");
		    	            }
    		    	        $_SESSION['rid']=$id;
						    header('location:user/recharge_home.php');
    		    	    }
	    		        else
		    	        {   
    		    	        setcookie ("member_name",$username, time()+(86400*30));
	    		            setcookie ("member_pwd", $password, time()+(86400*30));
		    	            $_SESSION['rid']=$id;
					    	header('location:user/recharge_home.php');
			            }
					}
				}
			}
		}
		elseif($sub==20)
		{
			$query1="select * from distributer where Userid='$username'";
			$run1=mysqli_query($con,$query1);
			$row1=mysqli_num_rows($run1);
			if($row1<1)
			{
			    echo "<center><h3 style='color:red; background:white; padding:10px'>User Id Does Not Correct !</h3></center>";
			}
			else
			{
				$query="select * from distributer where Userid='$username' and Password='$password'";
				$run=mysqli_query($con,$query);
				$row=mysqli_num_rows($run);
				if($row<1)
				{
				    echo "<center><h3 style='color:red; background:white; padding:10px'>Password Does Not Correct !</h3></center>";
				}
				else
				{
					$query1="select * from distributer where Userid='$username' and Password='$password' and Active=0";
					$run1=mysqli_query($con,$query1);
					$row1=mysqli_num_rows($run1);
					if($row1<1)
					{
						echo "<center><h3 style='color:red; background:white; padding:10px'>User Id Does Not Active !</h3></center>";
					}
					else
					{
						$data=mysqli_fetch_assoc($run1);
						$id=$data['Userid'];
			            if(empty($remember))
	        		    {
		        	        if(isset($_COOKIE["member_name"]))
			                {
			                    setcookie ("member_name","");
    			            }
	       		            if(isset($_COOKIE["member_pwd"]))
    		    	        {
	    		                 setcookie ("member_pwd", "");
		    	            }
					    	$_SESSION['did']=$id;
					    	header('location:distributer/recharge_home.php');
    		    	    }
	    		        else
		    	        {   
    		    	        setcookie ("member_name",$username, time()+(86400*30));
	    		            setcookie ("member_pwd", $password, time()+(86400*30));
	    					$_SESSION['did']=$id;
		    				header('location:distributer/recharge_home.php');
			            }
					}
				}
			}
		}
		elseif($sub==30)
		{
			$query1="select * from masterdis where Userid='$username'";
			$run1=mysqli_query($con,$query1);
			$row1=mysqli_num_rows($run1);
			if($row1<1)
			{
			    echo "<center><h3 style='color:red; background:white; padding:10px'>User Id Does Not Correct !</h3></center>";
			}
			else
			{
				$query="select * from masterdis where Userid='$username' and Password='$password'";
				$run=mysqli_query($con,$query);
				$row=mysqli_num_rows($run);
				if($row<1)
				{
					echo "<center><h3 style='color:red; background:white; padding:10px'>Password Does Not Correct !</h3></center>";
				}
				else
				{
					$query1="select * from masterdis where Userid='$username' and Password='$password' and Active=0";
					$run1=mysqli_query($con,$query1);
					$row1=mysqli_num_rows($run1);
					if($row1<1)
					{
						echo "<center><h3 style='color:red; background:white; padding:10px' >User Id Does Not Active !</h3></center>";
					}
					else
					{
						$data=mysqli_fetch_assoc($run1);
						$id=$data['Userid'];
			            if(empty($remember))
	        		    {
		        	        if(isset($_COOKIE["member_name"]))
			                {
			                    setcookie ("member_name","");
    			            }
	       		            if(isset($_COOKIE["member_pwd"]))
    		    	        {
	    		                 setcookie ("member_pwd", "");
		    	            }
					    	$_SESSION['mid']=$id;
						    header('location:md/recharge_home.php');
    		    	    }
	    		        else
		    	        {   
    		    	        setcookie ("member_name",$username, time()+(86400*30));
	    		            setcookie ("member_pwd", $password, time()+(86400*30));
	    					
					    	$_SESSION['mid']=$id;
						    header('location:md/recharge_home.php');
			            }
					}
				}
			}
		}
		else
		{
			echo "<center><h3 style='color:red; background:white; padding:10px'>User Id does not correct !</h3></center>";
		}
	}
	ob_end_flush();
?>
<html>
<head>
	<meta charset="utf-8">
	<title>LLP Recharge</title>
<style>
		body{
	background:url('bg.jpg');
	background-size:cover;
	margin:0;
	padding:0;
	font-family:sans-serif;
	background-size:cover;
}
.box{
	position:absolute;
	top:50%;
	left:50%;
	transform:translate(-50%,-50%);
	background:rgba(0,0,0,.6);
	width:420px;
	height:540px;
	padding:5px 20px;
	box-sizing:border-box;
	box-shadow:0 20px 25px rgba(0,0,0,.5);
	border-radius:10px;
}
.box a{font-size:35px; font-weight:bold; text-decoration:none; color:orange; Margin:10 0 0 65px;  position:relative;}
.box a:hover{color:#d9bd97;}
.box h2{
	margin:0 0 30px;
	padding:0;
	color:#fff;
}
.box .inputbox{
	position:relative;
	
}
table{width:380px; cellpadding:;}
table input{
	width:100%;
	height:40px;
	padding:4px 5px;
	font-size:16px;
	letter-spacing:1px;
	color:#fff;
	border:1px solid #fff;
	border-radius:5px;
	outline:none;
	background:transparent;
	input:focus{outline:none;}
}
table td{padding:30 3px;}
.box input[type="submit"]
{
    width:100%;
    height:50px;
	background:transparent;
	border:none;
	color:#111;
	background:orange;
	padding:5px 10px;
	cursor:pointer;
	border-radius:25px;
	margin-top:0px;
	font-size:35px;
	outline:none;
}
.box input[type="submit"]:focus{outline:none;}
#b:hover{background:#d9bd97; color:black;}
#eye{width:40px; height:40px; margin:10 0 0 10px; cursor:pointer;}
#p1{color:white; margin:0;}
#p2{color:white; margin:0;}
table img{width:40px; height:40px;}
#fp{text-decoration:none; font-size:17px; color:white; float:right; margin:20 10 0 0px; }
#fp:hover{color:orange;}
#rmb{width:20px; height:20px; margin:20 0px; color:white; float:left; }
#rmbfont{color:white; font-size:17px; float:left; margin:20 0 0 5px;}

</style>
    <script>
        function Show()
        {
            var show = document.getElementById("pwd");
            if(show.type=="password")
            {
                show.type="text";
                document.getElementById("eye").src="eyeopen.png";
            }
            else
            {
                show.type="password";
                document.getElementById("eye").src="eyeclose.png";
            }
        }
    </script>
</head>
<body>
	<div class="box">
	    <a href="index.php">LLP RECHARGE</a><hr><br>
		<h2>Login</h2>
		<form method="post">
		    <table border="0" >
		        <tr>
		            <td><img src="user.png"></img></td>
			        <td><input type="text" name="uname"  value="<?php if(isset($_COOKIE["member_name"])){echo $_COOKIE['member_name'];}?>" required></td>
				</tr>
		    	<tr>
			        <td>
			            <img src="pwd.png"></img>
			        </td>
			        <td>
			            <input type="password" name="upass" id="pwd" value="<?php if(isset($_COOKIE["member_pwd"])){echo $_COOKIE['member_pwd'];}?>" required>
			         </td>
			         <td>
			    	    <span><img src="eyeclose.png" onclick="Show()" id="eye"></img></span>
			    	</td>
			    </tr>
			    <tr>
			        <td colspan="3"><input type="submit" value="LOGIN NOW" id="b" name="login"></td>
			    </tr>
			</table>
			<input type="checkbox" name="remember" id="rmb" <?php if(isset($_COOKIE["member_name"])){ ?> checked <?php } ?>> <p id="rmbfont">Remember Me?</p>
			<a href="http://www.llprecharge.com/Forget_Password.php" id="fp" target="_blank">Forget Password?</a>
		</form>
	</div>
</body>
</html>