<?php session_start();
?>
<?php ob_start(); ?>
<?php

if (isset($_SESSION['number']) || isset($_COOKIE['number'])) {
  header('Location:online_order');
}

?>
<?php include("conn.php"); ?>
<!DOCTYPE html>
<html lang="en">
  <?php $page='Login'?>
  <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <!-- Latest compiled and minified CSS -->
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">

        <!--Table cdn-->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
        <!-- Bootstrap DataTable CSS -->
        <link rel="stylesheet" href="https://cdn.datatables.net/1.10.21/css/dataTables.bootstrap4.min.css">
        <link rel="stylesheet" href="https://cdn.datatables.net/2.0.5/css/dataTables.dataTables.css">
        <link rel="stylesheet" href="https://cdn.datatables.net/buttons/3.0.2/css/buttons.dataTables.css">
    
        <!---Fontawesome CDN-->
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
        <!-- jQuery library -->
        <script src="https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.slim.min.js"></script>
    
        <!-- Popper JS -->
        <script defer src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
    
        <!-- Latest compiled JavaScript -->
        <script defer src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"></script>
       


        <link rel="preconnect" href="https://fonts.googleapis.com">
        <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
        <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@500&display=swap" rel="stylesheet">
        <link href='https://fonts.googleapis.com/css?family=Convergence' rel='stylesheet'>


        <!--JS AOS-->
        <link rel="stylesheet" href="https://unpkg.com/aos@next/dist/aos.css" />
    
    
          <!-- owl carousel css link -->
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css">
      
       <!-- owl carousel theme.css link -->
       <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.theme.default.min.css">  
    
       <!-- owl carousel js file -->
        <script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"></script>
    

        <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>  
          
           <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>  
        <!--video play button cdn-->
          <!-- Icon Font Stylesheet -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.4.1/font/bootstrap-icons.css" rel="stylesheet">
        <!--graph cdn-->
        <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js"></script>
        <script src="https://www.gstatic.com/charts/loader.js"></script>
    <!---Fontawesome CDN-->
    <script src='https://kit.fontawesome.com/a076d05399.js' crossorigin='anonymous'></script>
        <!-- google font--->
        <link rel="preconnect" href="https://fonts.gstatic.com">
        <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300&display=swap" rel="stylesheet">
        
        <?php 
$color_mod='';
$color_mod=2; 
    


   

$sql="select * from store_details order by id desc";
$result = mysqli_query($conn,$sql)or die( mysqli_error($conn));
while ($row=mysqli_fetch_array($result)) {
 $data=$row['id'];
   $store_name=$row['name'];
   $c1=$row['first_contact'];
   $c2=$row['second_contact'];
   $store_email=$row['email'];
   $logo=$row['logo'];
   $location=$row['location'];
   $w_H=$row['working_hours'];
   $website=$row['website'];
   $store_image=$row['logo'];

   




}
?>

        <title> <?php echo $store_name ?> <?php echo $page ?></title>
        <link rel="icon" href="image/<?php echo $store_image ?>" type="image/x-icon">
        <?php
        $color=1;
        $color=$color_mod;

        if ($color==1) {
            $body_color='black';
            $body_text='antiquewhite';
            $nav_color=' #1D211C';
            $nav_text='antiquewhite';
            $menu_b_color=' #1C0601';
        }
        elseif($color==2){
            $body_color='#EDF2F1FF';
            $body_text='black';
            $nav_color='#982BAD';
            $nav_text='antiquewhite';
            $menu_color='#982BAD';
            $menu_b_color='#044763';
        }
       
        
        ?>
    
    </head>
<style>
          body {

  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: 100% 100%;
  font-family: 'Convergence'!important;
}

.login {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width:600px;
   
  }
    @media only screen and (max-width: 425px){
    .login {
     
        width: 300px;
      }
    }
     </style>
     
     <?php

include("conn.php");

if($_SERVER["REQUEST_METHOD"]=="POST"){
   $number=$_POST["number"];
   $pass=$_POST["password"];
   
//to prevent php injection

$number=stripcslashes($number);
$pass=stripcslashes($pass);


$sql = "SELECT * FROM customers WHERE number='$number' AND password ='$pass'";

$result=mysqli_query($conn,$sql);

   $row=mysqli_fetch_array($result);

   if($row["number"]==$number && $row['password'] == $pass  )
   {   
     $_SESSION['fname']=$row["fname"];
         $_SESSION['number']=$row["number"];
         $_SESSION['customers_id']=$row["customer_id"];

   setcookie('number',$row['number'],time()+60*60*24*30);
      
       echo"<script>alert('Login Successful'); window.location.href='online_order'</script>";
        
}
        
        else{
         echo"<script>alert('Your number or password is incorrect!'); </script>";
        }

   } 






?>
<body>

          <div class="login bg-light border ">
    
   
    <form method="post" class="  p-2 mt-2 text-center">
        <img src="logo/<?php echo $store_image?>" alt="<?php echo $store?>" height=150>
        <h5><?php echo $store_name?></h5>
        <h4>Login</h4>
        <div class="form-group mt-2">
            <label for="exampleInputEmail1">User phone number</label>
          <input type="number" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" name="number" placeholder="Enter number" required>
          <label for="exampleInputEmail1">Password</label>
          <input type="password" name="password" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Password">
        <button type="submit" class="btn btn-primary mt-4">Login</button>
        </div>
        <p class="text-center m-4"> Don't have account? <a href="online_register" class="text-primary   ">Register</a></p>
      </form>



        

 



    </div>
    
    <!--  isotope plugin cdn  -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.isotope/3.0.6/isotope.pkgd.min.js" integrity="sha256-CBrpuqrMhXwcLLUd5tvQ4euBHCdh7wGlDfNz8vbu/iI=" crossorigin="anonymous"></script>
    <script src="js/script.js"></script>

</body>

</html>