Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4.  
  5. $servername = "localhost";
  6. $username = "root";
  7. $password = "";
  8. $dbname = "kci_inventory";
  9.  
  10. // Create connection
  11. $conn = new mysqli($servername, $username, $password, $dbname);
  12. // Check connection
  13. if ($conn->connect_error) {
  14.     die("Connection failed: " . $conn->connect_error);
  15. }
  16.  
  17. $sql = "SELECT * FROM tbllogin WHERE username='".$_POST['username']."'";
  18. $result = $conn->query($sql);
  19.  
  20. if ($result->num_rows > 0) {
  21.     $row = $result->fetch_assoc();
  22.    
  23.     if(md5($_POST['password']) == $row['password']){
  24.         $_SESSION['sudahlogin']='ya';
  25.         header('location: index.php');
  26.     } else {
  27.         $_SESSION['sudahlogin']='belum';
  28.         header('location: /latihan/pages/examples/login.php');
  29.     }
  30.    
  31. } else {
  32.     $_SESSION['sudahlogin']='belum';
  33.     header('location: /latihan/pages/examples/login.php');
  34. }
  35. $conn->close();
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement