Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. <?php
  2.  
  3. $con = new mysqli("localhost", "root", "root", "test");
  4. if ($con->connect_errno) {
  5. echo "Fallo al conectar a MySQL: (" . $con->connect_errno . ") " . $con->connect_error;
  6. }
  7.  
  8. $username = $_POST['username'];
  9. $password = $_POST['password'];
  10.  
  11. $sql = "SELECT * FROM users WHERE username = '$username'";
  12. $result = $con->query($sql);
  13.  
  14. if ($result->num_rows == 1){
  15. $row = $result->fetch_assoc();
  16. $hash = $row['password'];
  17.  
  18. if(password_verify($password, $hash)){
  19. echo "Yes <br />" . $hash;
  20. } else {
  21. echo "No<br/>";
  22. echo "" . $hash . "<br/>";
  23. echo $password;
  24.  
  25. }
  26. }
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement