Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2017
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. if (isset($_POST['login']))
  2.  
  3. { $username = mysqli_real_escape_string($con,$_POST['username']);
  4. $pwd = md5($_POST['password']);
  5.  
  6. if (isset($username) == true && isset($pwd) == true){
  7.  
  8. $login = login($username, $pwd);
  9.  
  10. var_dump($login);
  11. if($login != null) {
  12.  
  13. $_SESSION ['user_id'] = $login ['buss_id'];
  14. $_SESSION ['usernameholder'] = $login ['username'];
  15. ob_start();
  16.  
  17. if ($login['level'] =='1')
  18. {?>
  19. <script>
  20. window.location.href = "sadmin/index.php";
  21. </script> <?php }
  22. else if($login['level'] =='2') { ?>
  23. <script>
  24. window.location.href = "user_admin/index.php";
  25. </script>
  26.  
  27. <?php } else if($login['level'] =='3') { ?>
  28. <script>
  29. window.location.href = "reps/index.php";
  30. </script>
  31. <?php
  32. } /* end of login levels. */
  33.  
  34.  
  35. } /* /if $login !=null */
  36. } /* /if $login = login */
  37. } /* / if isset el $_POST */
  38.  
  39. function login($username, $password)
  40. { $db_host="localhost";
  41. $db_username="root";
  42. $db_password="";
  43. $db_name="dbname";
  44. $con=mysqli_connect($db_host, $db_username,$db_password, $db_name);
  45.  
  46. $qry = "SELECT * FROM `businesses` WHERE `username` = '$username' AND `password` = '$password' AND `active` = 1 LIMIT 1";
  47. $sql = mysqli_query($con,$qry);
  48. while($row = mysqli_fetch_array($sql))
  49. {
  50. return $row;
  51. } }
  52.  
  53. $qry2 = "SELECT * FROM `employees` WHERE `username` = '$username2' AND `password` = '$password2' AND `active` = 1 LIMIT 1";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement