Guest User

Untitled

a guest
Nov 29th, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. $host = 'localhost';
  2. $dbname = 'idolisetcg';
  3. $user = 'root';
  4. $password = '';
  5.  
  6. $connect = new PDO("mysql:host=$host;dbname=$dbname", $user, $password);
  7.  
  8. include("database_connection.php");
  9. if(isset($_POST["login"]))
  10. {
  11. if(empty($_POST["email"]) || empty($_POST["password"]))
  12. {
  13. $message = "<div class='alert alert-danger'>Both Fields are required</div>";
  14. }
  15. else
  16. {
  17. $query = "
  18. SELECT * FROM members
  19. WHERE email = :email
  20. ";
  21. $statement = $connect->prepare($query);
  22. $statement->execute(
  23. array(
  24. 'email' => $_POST["email"]
  25. )
  26. );
  27. $count = $statement->rowCount();
  28. if($count > 0)
  29. {
  30. $result = $statement->fetchAll();
  31. foreach($result as $row)
  32. {
  33. if(password_verify($_POST["password"], $row["password"]))
  34. {
  35. header("location:index.php");
  36. }
  37. else
  38. {
  39. $message = '<div class="alert alert-danger">Wrong Password</div>';
  40. }
  41. }
  42. }
  43. else
  44. {
  45. $message = "<div class='alert alert-danger'>Wrong Email Address</div>";
  46. }
  47. }
  48. }
  49.  
  50. $result = $statement->fetchAll();
  51. foreach($result as $row)
  52. {
  53. if(password_verify($_POST["password"], $row["password"]))
  54. { if(password_needs_rehash($row["password"], PASSWORD_DEFAULT)){
  55. $newhash = password_hash($_POST["password"], PASSWORD_DEFAULT);
  56. }
  57. header("location:index.php");
  58. }
  59.  
  60. $result = $statement->fetchAll();
  61. foreach($result as $row)
  62. {
  63. if(password_verify($_POST["password"], $row["password"]))
  64. { if(password_needs_rehash($row["password"], PASSWORD_DEFAULT) && md5($_POST["password"] === $row["password"]){
  65. $newhash = password_hash($_POST["password"], PASSWORD_DEFAULT);
  66. }
  67. header("location:index.php");
  68. }
Add Comment
Please, Sign In to add comment