<?php

session_start();

include 'conn.php';

if(isset($_SESSION['reid']))

{

	echo "<script>window.location='home.php';</script>";

}

$error_not_match=0;

$error_not_found=0;

if(isset($_POST['login_bt'])){

	$username=mysqli_real_escape_string($conn,$_POST['username']);

	$password=md5(mysqli_real_escape_string($conn,$_POST['password']));

	$usr_check=mysqli_query($conn,"SELECT * FROM ormsregister WHERE username='$username' and status='1'");

	if(mysqli_num_rows($usr_check)>0){

		$user_resalt=mysqli_fetch_array($usr_check);

		if($password==$user_resalt['password']){

			$_SESSION['reid']=$user_resalt['reid'];

			echo "<script>window.location='pay_desk.php';</script>";

		}

		else{

			//password not match

			$error_not_match=1;

		}

	}

	else{

		//not found		

		$error_not_found=1;

	}

}

?>

<!DOCTYPE html>
<html lang="en" class="h-100">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Login | Mobile Recharge and Billing System | ORMS | Dashbaord</title>
	
    <?php
	//require_once './favicon.php';
	?>
	
	<?php
	require_once 'headercss.php';
	?>

</head>

<body class="h-100">
    <div class="authincation h-100">
        <div class="container h-100">
            <div class="row justify-content-center h-100 align-items-center">
                <div class="col-md-6">
                    <div class="authincation-content">
                        <div class="row no-gutters">
                            <div class="col-xl-12">
                                <div class="auth-form">
									<p><center><img src="images/logo.gif" alt="" style="width:300px;"></center></p>
                                    <h4 class="text-center mb-4" style="font-weight:bold;color:#ffffff;">Login in User Panel</h4>
									<hr>
									<?php if($error_not_found==1){ ?> <div style="background: linear-gradient(red,darkred); color: white; padding: 10px; text-align: center;">User not found, Please try agian.</div> <?php }?>
									<?php if($error_not_match==1){ ?> <div style="background: linear-gradient(red,darkred); color: white; padding: 10px; text-align: center;">your enterd password not match, Please try agian.</div> <?php }?>
                                    <form action="index.php" method="POST" >
                                        <div class="form-group">
                                            <label style="font-weight:bold;color:#ffffff;"><strong>Username</strong></label>
                                            <input type="text" name="username" id="exampleInputUsername" class="form-control" placeholder="Enter Username">
                                        </div>
                                        <div class="form-group">
                                            <label style="font-weight:bold;color:#ffffff;"><strong>Password</strong></label>
                                            <input type="password" name="password" id="exampleInputPassword" class="form-control" placeholder="Enter Password">
                                        </div>
                                        <div class="text-center">
											<input type="submit" class="btn btn-primary btn-block" name="login_bt" value="Login" style="color: #ffffff;background-color: #4d8f04;border-color: #4d8f04;">
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <?php
	require_once 'footerjs.php';
	?>

</body>

</html>