Advertisement
Dominikus_22

login.php

Apr 24th, 2024
1,064
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.49 KB | None | 0 0
  1. <?php include 'koneksi.php';
  2. session_start() ?>
  3. <!DOCTYPE html>
  4. <html lang="en">
  5. <head>
  6.    <meta charset="UTF-8">
  7.    <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8.    <title>UKK 2024 | Website Galeri Foto</title>
  9.    <link rel="stylesheet" href="assets/css/bootstrap.min.css">
  10.    <link rel="stylesheet" href="assets/css/style.css">
  11. </head>
  12. <body class="bg-danger">
  13.    <div class="container">
  14.       <div class="row justify-content-center align-items-center vh-100">
  15.          <div class="col-5">
  16.             <div class="card">
  17.                <div class="card-body">
  18.                   <h4 class="card-title">Halaman Login</h4>
  19.                   <p class="card-title">Login Akun</p>
  20.                   <?php
  21.                   //ambil data yang di kirim kan oleh <form> dengan method post
  22.                   $submit = @$_POST['submit'];
  23.                   if ($submit == 'Login') {
  24.                      $username = $_POST['username'];
  25.                      $password = md5($_POST['password']);
  26.                      //cek apakah username dan password yang di masukan ke dalam <input> ada di database
  27.                      $sql = mysqli_query($conn, "SELECT * FROM user WHERE Username='$username' AND Password='$password'");
  28.                      $cek = mysqli_num_rows($sql);
  29.                      if ($cek != 0) {
  30.                         //ambil data dari database untuk membuat session
  31.                         $sesi = mysqli_fetch_array($sql);
  32.                         echo "<script> alert('Login Berhasil!!')</script>";
  33.                         $_SESSION['username'] = $sesi['Username'];
  34.                         $_SESSION['user_id'] = $sesi['UserID'];
  35.                         $_SESSION['email'] = $sesi['Email'];
  36.                         $_SESSION['nama_lengkap'] = $sesi['NamaLengkap'];
  37.                         echo '<meta http-equiv="refresh" content="0.8; url=./">';
  38.                      } else {
  39.                         echo "<script> alert('Login Gagal!!')</script>";
  40.                         echo '<meta http-equiv="refresh" content="0.8; url=login.php">';
  41.                      }
  42.                   }
  43.                   ?>
  44.                   <form action="login.php" method="post">
  45.                      <div class="form-group">
  46.                         <label>Username</label>
  47.                         <input type="text" class="form-control" name="username" required>
  48.                      </div>
  49.                      <div class="form-group">
  50.                         <label>Password</label>
  51.                         <input type="password" class="form-control" name="password" required>
  52.                      </div>
  53.                      <input type="submit" value="Login" class="btn btn-danger my-3" name="submit">
  54.                      <p>Belum Punya Akun? <a href="daftar.php" class="link-danger">Daftar Sekarang</a></p>
  55.                   </form>
  56.                </div>
  57.             </div>
  58.          </div>
  59.       </div>
  60.    </div>
  61.    <script src="assets/js/bootstrap.bundle.min.js"></script>
  62.    <div class="col-xl-12">
  63.       <p class="copy_right text-center">
  64.          <!-- Link back to Colorlib can't be removed. Template is licensed under CC BY 3.0. -->
  65.          Copyright &copy; All rights reserved | <i class="fa fa-heart-o" aria-hidden="true"></i> by <a href="https://www.instagram.com/zeapplefjx_dika/?igsh=M2R2aDZ0dXI3aTFr" target="_blank">IG : zeapplefjx_dika</a>
  66.          <!-- Link back to Colorlib can't be removed. Template is licensed under CC BY 3.0. -->
  67.       </p>
  68.    </div>
  69. </body>
  70. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement