Advertisement
Guest User

Untitled

a guest
Sep 14th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. <center>
  2. <?php
  3. include ("database.php");
  4. ?>
  5.  
  6. <?php
  7.  
  8. session_start();
  9.  
  10. $username = $_POST['username'];
  11. $password = $_POST['password'];
  12.  
  13. $query = "select role from users where
  14. username = '$username' and
  15. password = '$password'";
  16. $result = mysql_query ($query);
  17. if(!$result)
  18. {
  19. echo 'Cannot run query.';
  20. exit;
  21. }
  22. $row = mysql_fetch_assoc ($result);
  23.  
  24.  
  25. if ($username = '')
  26. {
  27. echo 'You are not authorized to view this page.';
  28. }
  29. else
  30. {
  31. $_SESSION['username']=$username;
  32. $role=$row['role'];
  33.  
  34. if ( $role == 1 )
  35. {
  36. header('Location: admin_center.php');
  37. }
  38. elseif ( $role == 2 )
  39. {
  40. header('Location: teacher_center.php');
  41. }
  42. else
  43. {
  44. header('Location: stundent_center.php');
  45. }
  46.  
  47. }
  48. ?>
  49. </center>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement