Advertisement
Guest User

login.php

a guest
Jan 13th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include('connection.php');
  4.  
  5. //perform check on username and password
  6. if(isset($_POST['username']) && isset($_POST['password'])){
  7. if (!empty($_POST['username']) && !empty($_POST['password'])) {
  8. $username = $_POST["username"];
  9. $password = $_POST["password"];
  10.  
  11. $sql = "SELECT employeeID, username, password, manager FROM employees WHERE username = '$username' LIMIT 1";
  12. $result = mysqli_fetch_object(mysqli_query($conn, $sql));
  13.  
  14. if($result->password == $password){
  15. $_SESSION['logged'] = true;
  16. $_SESSION['username'] = $username;
  17. $_SESSION['manager'] = $result->manager;
  18. $_SESSION['userID'] = $result->employeeID;
  19.  
  20. header('Location: index.php');
  21. /*
  22. if ($result->manager == 0) {
  23. header('Location: user_report.php');
  24. }
  25. elseif ($result->manager == 1) {
  26. header('Location: view_user_reports.php');
  27. }
  28. elseif ($result->manager == 2) {
  29. header('Location: view_user_reports.php');
  30. }
  31. elseif ($result->manager == 3) {
  32. header('Location: view_user_reports.php');
  33. }*/
  34.  
  35. }
  36. else{
  37. echo "Wrong email and/or password.";
  38. }
  39. }
  40. }
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement