Guest User

Untitled

a guest
Oct 24th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. $conn = new mysqli("localhost", "root", "", "mydb");
  2.  
  3. if (isset($_POST['btn_saves'])) {
  4. session_start();
  5. $checkUser = $conn->query("SELECT * from team WHERE username = '$_POST[username]' AND password = '$_POST[password]'");
  6.  
  7.  
  8. if ($checkUser->num_rows > 0) {
  9. $_SESSION['temp'] = "true";
  10. $user = $checkUser->fetch_assoc();
  11. $user_type = $checkUser->fetch_assoc();
  12. $_SESSION['user_id'] = $user['user_id'];
  13.  
  14. } else if ($checkUser->num_rows == 1) {
  15.  
  16. $logged_in_user = mysqli_fetch_assoc($results);
  17. if ($logged_in_user['user_type'] == 'admin') {
  18.  
  19. $_SESSION['user_id'] = $logged_in_user;
  20. header('location: admin_panel.php');
  21. }else{
  22. $_SESSION['user_id'] = $logged_in_user;
  23.  
  24. header('location: user_panel.php');
  25. }
  26. }
  27.  
  28. else{
  29. echo "<script>alert('error')</script>";
  30. }
  31. }
Add Comment
Please, Sign In to add comment