Exemplo n.º 1
0
 $password = isset($_POST['password']) ? trim($_POST['password']) : '';
 $userType = isset($_POST['userType']) ? trim($_POST['userType']) : '';
 if ($userType == 'customer') {
     $res = $u->getCustomerDetails($username, $password);
     $id = $res->getId();
     $passwordValue = $res->getPassword();
     $isValid = password_verify($password, $passwordValue);
     if ($username == $res->getCustomerName() && $isValid) {
         $_SESSION['user'] = $username;
         header("Location: customerHome.php?id={$id}");
     } else {
         print '<div class="alert alert-danger" role="alert"><strong>INVALID LOGIN ! </strong>' . strtoupper($username) . ' & ' . 'PASSWORD ENTERED DOES NOT MATCH IN OUR SYSTEM. ' . '</div>';
     }
 } else {
     if ($userType == 'employee') {
         $res = $u->getEmployeeDetails($username, $password);
         $id = $res->getEmpId();
         $passwordValue = $res->getPassword();
         $isValid = password_verify($password, $passwordValue);
         if ($username == $res->getEmployeeName() && $isValid) {
             $_SESSION['user'] = $username;
             header("Location: employeeHome.php?empId={$id}");
         } else {
             print '<div class="alert alert-danger" role="alert"><strong>INVALID LOGIN ! </strong>' . strtoupper($username) . ' & ' . 'PASSWORD ENTERED DOES NOT MATCH IN OUR SYSTEM. ' . '</div>';
         }
     } else {
         if ($userType == 'admin') {
             $res = $u->getAdminDetails($username, $password);
             $id = $res->getId();
             if ($username == $res->getAdminUserName() && $password == $res->getPassword()) {
                 $_SESSION['user'] = $username;