Advertisement
Guest User

Untitled

a guest
Dec 30th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. if($_SERVER["REQUEST_METHOD"] == "POST") {
  2. // username and password sent from form
  3. $username = mysqli_real_escape_string($link, $_POST['username']);
  4. $password = mysqli_real_escape_string($link, $_POST['password']);
  5.  
  6. $result = mysqli_query($link, "SELECT * FROM users WHERE username LIKE '$username' AND password LIKE '$password'");
  7.  
  8. if($result === FALSE) {
  9. die(mysql_error()); // TODO: better error handling
  10. }
  11.  
  12. while($row = mysqli_fetch_array($result))
  13. {
  14.  
  15. echo $row['username'];
  16. }
  17.  
  18. echo var_dump($result);
  19. $active = $row['active'];
  20.  
  21. $count = mysqli_num_rows($result);
  22.  
  23. // If result matched $username and $password, table row must be 1 row
  24.  
  25. if($count == 1) {
  26.  
  27. $_SESSION['login_user'] = $username;
  28.  
  29. // check the user_type
  30. if($row["user_type"] == "teacher")
  31. {
  32. header("Location: teacher.php")
  33. }
  34. elseif($row["user_type"] == "parent")
  35. {
  36. header("Location: parent.php")
  37. }
  38. elseif($row ["user_type"] == "student")
  39. {
  40. header("Location: student.php")
  41. }
  42. elseif($row ["user_type" == "HOD")
  43. {
  44. header("Location: HOD.php")
  45. }
  46. else {
  47. echo "no account type!";
  48.  
  49. }else {
  50. $error = "Your Login Name or Password is invalid";
  51. }
  52. }
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement