Advertisement
Guest User

Untitled

a guest
Oct 15th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. if(isset($_POST['submit'])){
  2. $username = (isset($_POST['username']))? $_POST['username'] : die("Please input a username!");
  3. $password = (isset($_POST['password']))? md5($_POST['password']):die("Please input a password");
  4.  
  5. if($stmt = $mysqli->prepare("SELECT username,id,role FROM users WHERE username = ? AND password = ? LIMIT 1" )){
  6. $stmt->bind_param("ss",$username,$password);
  7. $stmt->execute();
  8.  
  9. $res = $stmt->get_result();
  10. if($res->num_rows > 0){
  11. while($row = $res->fetch_assoc()){
  12.  
  13. $_SESSION['username'] = $row['username'];
  14. $_SESSION['id'] = $row['id'];
  15. $_SESSION['role'] = $row['role'];
  16.  
  17. header('location: dashboard.php');
  18. exit();
  19.  
  20. }
  21.  
  22. }else{
  23. echo "No username/password found with that combination";
  24. }
  25.  
  26. }else{
  27. echo "error";
  28. print_r($mysqli->error);
  29.  
  30. }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement