Advertisement
Guest User

sintak login

a guest
Oct 28th, 2018
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.54 KB | None | 0 0
  1. <?php
  2. require 'inc/function.php';
  3.  
  4. if (isset($_POST["login"])  ) {
  5.  
  6.    $user = $_POST['user'];
  7.     $pass = $_POST['pass'];
  8.  
  9.    $result = mysqli_query($con, "SELECT * FROM tb_user WHERE username = '$user'" );
  10.  
  11.     //cek username
  12.     if (mysqli_num_rows($result) === 1 ) {
  13.  
  14.         //cek password
  15.         $row = mysqli_fetch_assoc($result);
  16.         if (password_verify($pass, $row["password"])){
  17.         header("location: index.php?info");
  18.  
  19.         exit;
  20.         }
  21.        
  22.     }
  23.  
  24.     $error = true;
  25. }
  26.  
  27.  
  28. ?>
  29.  
  30.  
  31.  
  32. <link rel="stylesheet" type="text/css" href="css/in.css">
  33. <body>
  34.     <?php if ( isset($error)): ?>
  35.             <script type="text/javascript">alert("password dan username salah");</script>
  36.          <?php endif ?>
  37.     <div id="canvas">
  38.         <div class="judul">
  39.            FORM LOGIN  
  40.         </div>
  41.     </div>
  42.         <form action="" method="post" class="in">
  43.                     <p style="margin-top: 40px;">
  44.                     <input type="text" name="user" placeholder="Username" class="input" />
  45.                     </p>
  46.                     <p style="margin-top: 20px;">
  47.                     <input type="password" name="pass" placeholder="Password" class="input" />
  48.                     </p>
  49.                     <a href="" class="l">Lupa Password</a>
  50.                 <input type="submit" value="SING IN" class="tombol" name="login"  />
  51.                 <p class="akun">Belum Punya Akun
  52.                     <a href="index.php?regis" class="up">SING UP</a>
  53.                 </p>
  54.            
  55.         </form>
  56.    
  57. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement