Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Password_hash
xazerek
post
Post #1





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 21.05.2013

Ostrzeżenie: (0%)
-----


Witam.
Co robię źle? Chcę wyciągnąć hasło z bazy danych i porównać je z tym wpisanym w formularzu logowania.



  1. <?php
  2. require_once("config.php");
  3.  
  4. $auth_host = $GLOBALS['auth_host'];
  5. $auth_user = $GLOBALS['auth_user'];
  6. $auth_pass = $GLOBALS['auth_pass'];
  7. $auth_dbase = $GLOBALS['auth_dbase'];
  8.  
  9.  
  10. $db = mysqli_connect($auth_host, $auth_user, $auth_pass,$auth_dbase) or die("Error " . mysqli_error($db));
  11.  
  12.  
  13. $user_name = mysqli_real_escape_string($db,$_POST['name']);
  14. $user_password = mysqli_real_escape_string($db,$_POST['password']);
  15.  
  16. $sql = mysqli_query($db,"SELECT * FROM account WHERE (user = '$user_name') AND banned IS NULL");
  17. $rows= mysqli_num_rows($sql);
  18.  
  19. if($rows > 0)
  20. {
  21. if(password_verify($user_password, $rows['password']))
  22. {
  23. echo "Logged In";
  24. }
  25. else
  26. {
  27. echo "Password Wrong";
  28. }
  29. }
  30. else
  31. {
  32. echo "Password Wrong";
  33. }
  34.  
  35. mysqli_close($db);
  36. ?>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 09:59