<?php  //Start the Session

session_start();

 require('connectdb.php');
 require_once 'class.admin.php';
//3. If the form is submitted or not.
//3.1 If the form is submitted
if (isset($_POST['email']) and isset($_POST['upass'])){
//3.1.1 Assigning posted values to variables.
$email = $_POST['email'];
$upass = $_POST['upass']; 

//3.1.2 Checking the values are existing in the database or not
$query = "SELECT * FROM admin WHERE email='$email' and upass='$upass'";
 
$result = mysqli_query($connection, $query) or die(mysqli_error($connection));
$count = mysqli_num_rows($result);
//3.1.2 If the posted values are equal to the database values, then session will be created for the user.
if ($count == 1){
$_SESSION['email'] = $email;
}else{
//3.1.3 If the login credentials doesn't match, he will be shown with an error message.
$msg = "<div class='alert alert-danger'>
						<button class='close' data-dismiss='alert'>&times;</button>
						  Invalid Email or Password!
                   
			  </div>";
}
}
//3.1.4 if the user is logged in Greets the user with message
if (isset($_SESSION['email'])){
$email = $_SESSION['email'];
header('Location: index.php');
 
}else{}
//3.2 When the user visits the page first time, simple login form will be displayed.
?>

   
 

<html>

<head>
  <link rel="stylesheet" href="css/style.css">
  <link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet">
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <link rel="stylesheet" href="path/to/font-awesome/css/font-awesome.min.css">
  <title> Staff Panel Login | <?php echo $site_title; ?> </title>
  <meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
 <!-- Place favicon in the favicon directory -->
 <link rel="apple-touch-icon" sizes="180x180" href="assets/favicon/.png">
 <link rel="icon" type="image/png" sizes="32x32" href="assets/favicon/favicon.png">
 <link rel="icon" type="image/png" sizes="16x16" href="assets/favicon/favicon.png"> 
  <style>

        body {
        background-color: #daf4f2;
        font-family: 'Ubuntu', sans-serif;
    }
    
    .main {
        background-color: #adcfd8;
        width: 320px;
        height: 400px;
        margin: 7em auto;
        border-radius: 1.5em;
        box-shadow: 0px 11px 35px 2px rgba(0, 0, 0, 0.14);
    }
    
    .sign {
        padding-top: 40px;
        color: green;
        font-family: 'Ubuntu', sans-serif;
        font-weight: bold;
        font-size: 14px;
    }
    
    .un {
    width: 70%;
    color: rgb(38, 50, 56);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 1px;
    background: rgba(136, 126, 126, 0.04);
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    outline: none;
    box-sizing: border-box;
    border: 2px solid rgba(0, 0, 0, 0.02);
    margin-bottom: 50px;
    margin-left: 46px;
    text-align: center;
    margin-bottom: 27px;
    font-family: 'Ubuntu', sans-serif;
    }
    
    form.form1 {
        padding-top: 40px;
    }
    
    .pass {
            width: 76%;
    color: rgb(38, 50, 56);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 1px;
    background: rgba(136, 126, 126, 0.04);
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    outline: none;
    box-sizing: border-box;
    border: 2px solid rgba(0, 0, 0, 0.02);
    margin-bottom: 50px;
    margin-left: 46px;
    text-align: center;
    margin-bottom: 27px;
    font-family: 'Ubuntu', sans-serif;
    }
    
   
    .un:focus, .pass:focus {
        border: 2px solid rgba(0, 0, 0, 0.18) !important;
        
    }
    
    .submit {
      cursor: pointer;
        border-radius: 5em;
        color: #fff;
        background: linear-gradient(to right, #ea8315, #ea8315);
        border: 0;
        padding-left: 40px;
        padding-right: 40px;
        padding-bottom: 10px;
        padding-top: 10px;
        font-family: 'Ubuntu', sans-serif;
        margin-left: 28%;
        font-size: 13px;
        box-shadow: 0 0 20px 1px rgba(0, 0, 0, 0.04);
    }
    
    .forgot {
        text-shadow: 0px 0px 3px rgba(117, 117, 117, 0.12);
        color: #E1BEE7;
        padding-top: 15px;
    }
    
    a {
        text-shadow: 0px 0px 3px rgba(117, 117, 117, 0.12);
        color: #E1BEE7;
        text-decoration: none
    }
    
    @media (max-width: 600px) {
        .main {
            border-radius: 0px;
        }
        
        
</style>

</head>

<body>
  
                
 
	 <div class="main">
	     <br>
	  <center><img src="../assets/img/logo.png" height="40px"/></center>
	                          
 
	     
                      <p class="sign" align="center">Super Admin Login</p>
                       
 
                   
                    <!-- END login-desc -->
                    <!-- BEGIN login-form --> 
                    
                        <form class="form1" method="POST">
                            
                              <?php if (isset($msg)) echo $msg; ?>
                            
                            <input type="text"  name="email" class="un " placeholder="Username" autofocus required />
                              <input type="text"  name="upass" class="un " placeholder="Password" autofocus required />

                        <button type="submit" name="code"   class="submit" align="center" >Access Backend</button>
                     
             </div>    </div>



                </form>
     
</body>

</html>
      
     
