Advertisement
Guest User

Untitled

a guest
Feb 24th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $_SESSION['user_login'] = false;
  4. }
  5. ?>
  6.  
  7. <li>
  8. <div style="margin-left: 15px ;margin-right:15px ; text-align: center">
  9. <?php
  10. if (!$_SESSION['user_login']){
  11. echo '<a href="View/login.php" class="btnprofile" style="background-image:url(./img/defaullt_profile.jpg)" ></a>';
  12. }
  13. else{
  14. echo '<a href="View/profile.php" class="btnprofile" style="background-image:url(coba.jpg)" ></a>';
  15. }
  16. ?>
  17. </div>
  18. </li>
  19.  
  20. <?php
  21. include_once '../Dao/UserDaoImpl.php';
  22. include_once '../Entity/USER.php';
  23. include_once '../util/PDOUTIL.php';
  24. session_start();
  25. $loginPressed = filter_input(INPUT_POST, 'btnLogin');
  26. if (isset($loginPressed)) {
  27. $userDao = new UserDaoImpl();
  28. $username = filter_input(INPUT_POST, 'txtUsername');
  29. $password = filter_input(INPUT_POST, 'txtPassword');
  30. $md5Password = md5($password);
  31. $userLogin = new User();
  32. $userLogin->setUsername($username);
  33. $userLogin->setPassword($md5Password);
  34. /* @var $arrResult User */
  35. $arrResult = $userDao->login($userLogin);
  36. $longname = $arrResult['longname'];
  37. $email = $arrResult['email'];
  38. $gender = $arrResult['gender'];
  39. $dateofbirth = $arrResult['dateofbirth'];
  40. $cekrole = $arrResult['role'];
  41. $profile = $arrResult['profile'];
  42. if (isset($arrResult) && !empty($arrResult['name'])) {
  43. if ($cekrole == 'admin') {
  44. $_SESSION['user_login'] = TRUE;
  45. $_SESSION['user_name'] = $arrResult['username'];
  46. header('location:homeadmin.php');
  47. } elseif ($cekrole == 'employee') {
  48. $_SESSION['user_login'] = TRUE;
  49. $_SESSION['user_name'] = $arrResult['username'];
  50. $_SESSION['namauser'] = $username;
  51. header('location:homeemployee.php');
  52. } elseif ($cekrole == 'member') {
  53. $_SESSION['user_login'] = TRUE;
  54. $_SESSION['user_name'] = $arrResult['username'];
  55. $_SESSION['profile'] = $profile;
  56. $_SESSION['longname'] = $longname;
  57. $_SESSION['email'] = $email;
  58. $_SESSION['dateofbirth'] = $dateofbirth;
  59. $_SESSION['gender'] = $gender;
  60. header('location:../index.php');
  61. }
  62. }
  63. else{
  64. $message = 'Id atau Password salah';
  65. echo "<script type='text/javascript'>alert('$message');</script>";
  66. }
  67. }
  68. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement