Advertisement
qoqvja-

stmt native sebelum revisi

Nov 21st, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. <?php
  2.  
  3. if (isset($_POST['submit'])) {
  4.  
  5.  
  6.  
  7. $username = filter_input(INPUT_POST,'username',FILTER_SANITIZE_STRING);
  8. $password = filter_input(INPUT_POST,'password',FILTER_SANITIZE_STRING);
  9.  
  10. $sql = "SELECT * FROM users WHERE username=:username";
  11.  
  12. $query_param = array(":username" => $username);
  13.  
  14. try {
  15. $stmt = $db->prepare($query);
  16. $result = $stmt->execute($query_params);
  17. } catch (Exception $error) {
  18. die("error query failed");
  19. }
  20. $row = $stmt->fetch();
  21.  
  22. if ($row) {
  23. if (password_verify($password,$row['password'])) {
  24. session_start();
  25. $_SESSION['user'] = $row;
  26. header("Location: index.php");
  27. }
  28. }
  29. }
  30.  
  31.  
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement