<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <!-- 
    - primary meta tags
  -->
  <title>Fixit - Explore new horizons</title>
  <meta name="title" content="Fixit - Right place to own your car">
  <meta name="description" content="This is a vehicle repair html template made by codewithsadee">

  <!-- 
    - favicon
  -->
  <link rel="shortcut icon" href="favicon.svg" type="image/svg+xml">

  <!-- 
    - google font link
  -->
  <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=Chakra+Petch:wght@400;600;700&family=Mulish&display=swap"
    rel="stylesheet">

  <!-- 
    - material icon font
  -->
  <link rel="stylesheet"
    href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@40,600,0,0" />

  <!-- 
    - custom css link
  -->
  <link rel="stylesheet" href="login.css">

  <!-- 
    - preload images
  -->
  <!-- <link rel="preload" as="image" href="hero-banner.png">
  <link rel="preload" as="image" href="hero-bg.jpg">
 -->
</head>

<body>


  <main>
    <article>

      <!-- 
        - #HERO
      -->

      <section class="hero has-bg-image" aria-label="home" style="background-image: url('service-bg.jpg')">
        <div class="container">

          <div class="hero-content" id="#home">
             

  <div class="register_container">
    <div class="overlay">
      <!--gak ada konten-->
    </div>
<h1>
    <div class="titleDiv">
      <h1 class="title">MEMBER AREA</h1>
      <span class="subTilte">Write your data below</span>
    </div>


    <form action="" method="POST">
    <div class="rows grid">

      <!--user name-->
      <div class="row">
        <label for="username">User Name</label><br>
        <input type="text" id="username" name="username" placeholder="Enter Your Name" required>
      </div>


      <!--Password-->
      <div class="row">
        <label for="password">Password</label>
        <input type="password" id="password" name="password" placeholder="Enter Your Password" required>
      </div>


      
      <!--Submit Button-->
      <div class="row">
        <input type="submit" id="submitBtn" name="submit" value="Login" required ><br>

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


          </div>
        </div>
      </section>


<!-- Program php Login -->

      <?php
        // juka user click tombol submit, maka...
      if(isset($_POST['submit'])){
        // untuk nyambungin ke file lain
        session_start();
        include 'konek.php';
          // agar mencega dari adanya selain huruf dan angka
        $username = mysqli_real_escape_string($conn,$_POST['username']);
        $password = mysqli_real_escape_string($conn,$_POST['password']);
          // untuk memastikan pw dan nama sesuai dengan yg ada di database
        $cek = mysqli_query($conn, "SELECT * FROM pelanggan WHERE username = '".$username."'AND password = '".($password)."'");
        if(mysqli_num_rows($cek) > 0) {
          $c = mysqli_fetch_object($cek);
          // jika status login, maka bisa akses apapun file yg nyambung
          $_SESSION['status_login'] = true;
          // bisa memanggil nama user di file lain
          $_SESSION['a_global'] = $c;
          //menyimpan data dalam variabel
          $_SESSION['id'] = $c->costumer_id;
          // jika benar semua, maka akan dibawah ke file dashboard
          echo '<script>window.location="buying.php"</script>';
        } 
        else{
          echo '<script>alert("Username or Password wrong!")</script>';
        }



        
      }
    ?>




      <!-- 
        - #SERVICE
      -->
<!-- 
      <section class="section service has-bg-image" aria-labelledby="service-label"
        style="background-image: url('service-bg.jpg')">
        <div class="container">

        </div>
      </section>
 -->




    

      





  <!-- 
    - custom js link
  -->
  <script src="script.js"></script>

</body>

</html>