Advertisement
Guest User

Untitled

a guest
Jun 18th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. include '../../model/config.php';
  5. include 'success.php';
  6.  
  7. $username = $koneksi->real_escape_string($_POST['username']);
  8. $password = $koneksi->real_escape_string($_POST['password']);
  9.  
  10. $query = "SELECT * FROM user WHERE username='$username'";
  11. $result = $koneksi->query($query);
  12. $count = $result->num_rows;
  13.  
  14. //Jika User Ada
  15. if($count > 0){
  16. $cetak = $result->fetch_assoc();
  17. $passHash = $cetak['password'];
  18. $status = $cetak['status'];
  19. if(password_verify($password,$passHash) && $status == 0){
  20. $_SESSION['nama_user'] = $cetak['nama_user'];
  21. $_SESSION['id'] = $cetak['id_user'];
  22. ?>
  23. <script>
  24. $(document).ready(function(){
  25. swal({
  26. title:'Success!',
  27. text:'Anda Berhasil Login!',
  28. type:'success'
  29. },
  30. function(isConfirm){
  31. if(isConfirm){
  32. window.location=("../../view/admin.php");
  33. }
  34. });
  35. });
  36. </script>
  37. <?php
  38. }else if(password_verify($password,$passHash) && $status == 1){
  39. $_SESSION['nama_user'] = $cetak['nama_user'];
  40. $_SESSION['id'] = $cetak['id_user'];
  41. ?>
  42.  
  43. <script>
  44. $(document).ready(function(){
  45. swal({
  46. title:'Success!',
  47. text:'Anda Berhasil Login!',
  48. type:'success'
  49. },
  50. function(isConfirm){
  51. if(isConfirm){
  52. window.location=("../../view/user.php");
  53. }
  54. });
  55. });
  56. </script>
  57. <?php
  58. }else{
  59. echo '<script>window.alert("Username/Password Salah!");window.location=("../../view/");</script>';
  60. }
  61. }else{
  62. echo '<script>window.alert("Tidak Ada Username Terdaftar!");window.location=("index.php");</script>';
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement