Guest User

Untitled

a guest
Aug 20th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $username = $_POST["txtUsername"];
  4. $password = $_POST["txtPassword"];
  5. $sql = "select count(*) from users where username=? and password=?";
  6.  
  7. $db = new mysqli("127.0.0.1", "root", "student", "todo");
  8.  
  9. $stmt = $db->prepare($sql);
  10.  
  11. //add parameters to sql
  12. $stmt->bind_param("ss", $username, md5($password));
  13.  
  14. $stmt->execute();
  15.  
  16. $stmt->bind_result($userCount);
  17. $stmt->fetch();
  18.  
  19. if($userCount > 0) {
  20. $_SESSION["USERNAME"] = $username;
  21. header("Location:tasks.html");
  22. } else {
  23. header("Location:login.html");
  24. }
  25. //DB <- mysqli ->prepare ->mysqli_stmt -> execute(sql) ->fetch()
  26. ?>
Add Comment
Please, Sign In to add comment