Advertisement
Guest User

Untitled

a guest
Apr 26th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. <?php
  2. include_once("config.php");
  3. session_start();
  4. $message = "";
  5.  
  6.  
  7. if (isset($_POST['username'])) {
  8. $username = ($_POST['username']);
  9. $password =md5($_POST['password']);
  10. $password = ($password);
  11.  
  12.  
  13. $sql = "SELECT * FROM user WHERE username = '$username' && password='$password'";
  14. $query = mysqli_query($conn, $sql);
  15. $row = mysqli_fetch_row($query);
  16. $userid = $row[0];
  17. $checkuser = $row[5];
  18. $checkpassword = $row[4];
  19. $type = $row[1];
  20. $name = $row[2];
  21. $surname = $row[3];
  22.  
  23. if ($username != $checkuser || $password != $checkpassword) {
  24. $message = " username or password entered is incorrect.";
  25. }
  26.  
  27. if ($username == $checkuser && $password == $checkpassword) {
  28. $_SESSION['username'] = $username;
  29. $_SESSION['type'] =$type;
  30. $_SESSION['name'] = $name;
  31. $_SESSION['surname'] = $surname;
  32. $_SESSION['userid'] = $userid;
  33.  
  34. if($_SESSION['type'] == "admin")
  35. {
  36. header("Location: adminindex.php");
  37.  
  38. }
  39. else{
  40.  
  41. header("Location: index.php");
  42. }
  43.  
  44.  
  45.  
  46. }
  47. }
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement