Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $_SESSION['user_login'] = false;
- }
- ?>
- <li>
- <div style="margin-left: 15px ;margin-right:15px ; text-align: center">
- <?php
- if (!$_SESSION['user_login']){
- echo '<a href="View/login.php" class="btnprofile" style="background-image:url(./img/defaullt_profile.jpg)" ></a>';
- }
- else{
- echo '<a href="View/profile.php" class="btnprofile" style="background-image:url(coba.jpg)" ></a>';
- }
- ?>
- </div>
- </li>
- <?php
- include_once '../Dao/UserDaoImpl.php';
- include_once '../Entity/USER.php';
- include_once '../util/PDOUTIL.php';
- session_start();
- $loginPressed = filter_input(INPUT_POST, 'btnLogin');
- if (isset($loginPressed)) {
- $userDao = new UserDaoImpl();
- $username = filter_input(INPUT_POST, 'txtUsername');
- $password = filter_input(INPUT_POST, 'txtPassword');
- $md5Password = md5($password);
- $userLogin = new User();
- $userLogin->setUsername($username);
- $userLogin->setPassword($md5Password);
- /* @var $arrResult User */
- $arrResult = $userDao->login($userLogin);
- $longname = $arrResult['longname'];
- $email = $arrResult['email'];
- $gender = $arrResult['gender'];
- $dateofbirth = $arrResult['dateofbirth'];
- $cekrole = $arrResult['role'];
- $profile = $arrResult['profile'];
- if (isset($arrResult) && !empty($arrResult['name'])) {
- if ($cekrole == 'admin') {
- $_SESSION['user_login'] = TRUE;
- $_SESSION['user_name'] = $arrResult['username'];
- header('location:homeadmin.php');
- } elseif ($cekrole == 'employee') {
- $_SESSION['user_login'] = TRUE;
- $_SESSION['user_name'] = $arrResult['username'];
- $_SESSION['namauser'] = $username;
- header('location:homeemployee.php');
- } elseif ($cekrole == 'member') {
- $_SESSION['user_login'] = TRUE;
- $_SESSION['user_name'] = $arrResult['username'];
- $_SESSION['profile'] = $profile;
- $_SESSION['longname'] = $longname;
- $_SESSION['email'] = $email;
- $_SESSION['dateofbirth'] = $dateofbirth;
- $_SESSION['gender'] = $gender;
- header('location:../index.php');
- }
- }
- else{
- $message = 'Id atau Password salah';
- echo "<script type='text/javascript'>alert('$message');</script>";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement