Guest User

Untitled

a guest
Mar 18th, 2019
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require 'setting/config.php';
  4. error_reporting(0);
  5. $username = $_POST['username'];
  6. $password = $_POST['password'];
  7. $login = $_POST['login'];
  8. if(isset($login)){
  9. $res = $conn->query("SELECT * FROM login where username='$username' and password='$password'");
  10. $row = $res->fetch_assoc();
  11. $name = $row['name'];
  12. $user = $row['username'];
  13. $pass = $row['password'];
  14. $type = $row['type_login'];
  15.  
  16. if($user==$username && $pass=$password){
  17. $_SESSION['sess_user_id'] = $row['name_login'];
  18. $_SESSION['sess_username'] = $row['username'];
  19. $_SESSION['sess_userrole'] = $row['type_login'];
  20.  
  21.  
  22. if($type=="admin"){
  23. $_SESSION['mysesi']=$name;
  24. $_SESSION['mytype']=$type;
  25. echo "<script>window.location.assign('index.php')</script>";
  26.  
  27. } else if($type=="user"){
  28. $_SESSION['mysesi']=$name;
  29. $_SESSION['mytype']=$type;
  30. echo "<script>window.location.assign('index.php')</script>";
  31.  
  32. } else if($type=="super"){
  33. $_SESSION['mysesi']=$name;
  34. $_SESSION['mytype']=$type;
  35. echo "<script>window.location.assign('super.php')</script>";
  36.  
  37. } else{
  38. $msg="your Login successfully !";
  39. }
  40. } else{
  41. $msg="your usernamae and password worng please try again!";
  42. }
  43. }
  44. ?>
  45.  
  46. <?php
  47. session_start();
  48. require 'setting/config.php';
  49.  
  50. if (!isset($_SESSION['mysesi']) && !isset($_SESSION['mytype'])=='admin')
  51. {
  52. echo "<script>window.location.assign('sign-in.php')</script>";
  53. }
  54. ?>
Add Comment
Please, Sign In to add comment