Advertisement
Guest User

Untitled

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