Advertisement
rafisbr

action_login.php

May 22nd, 2022
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require "config.php";
  4. if (isset($_COOKIE['login'])) {
  5. # code...
  6. if ($_COOKIE['login'] =='true') {
  7. # code...
  8. $_SESSION['username'] == true;
  9. }
  10. }
  11.  
  12.  
  13. $username = $_POST['username'];
  14. $password = $_POST['password'];
  15. $query=mysqli_query($koneksi, "SELECT * FROM users WHERE username='$username'");
  16. $h = mysqli_num_rows($query);
  17. $pw = mysqli_fetch_array($query);
  18. $pwnow = $pw['password'];
  19.  
  20. if ($h>0) {
  21. # code...
  22. if(password_verify($password, $pwnow)){
  23.  
  24.  
  25. $_SESSION['username'] = $username;
  26.  
  27.  
  28. // if (isset($_POST['remember'])) {
  29. // # code...
  30. // setcookie('login', 'true', time() + 30);
  31. // }
  32.  
  33. header("location: home.php");
  34. } else{
  35. echo '<script>
  36. alert ("PASSWORD SALAH");
  37. window.location.href="index.php";
  38. </script>';
  39. }
  40. }
  41. // else{
  42. // echo '<script>
  43. // alert ("LOGIN GAGAL");
  44. // window.location.href="index.php";
  45. // </script>';
  46. // }
  47.  
  48.  
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement