Advertisement
nedfire

PDOerror

Apr 18th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1.  
  2.  
  3. <?php
  4.  
  5. $servername="xx";
  6.  
  7. $username="xx";
  8.  
  9. $password="xx";
  10.  
  11. $dbname="xx";
  12.  
  13. $conn = new PDO("mysql:host=$servername;dbname=$dbname",$username, $password);
  14.  
  15. $conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
  16.  
  17. $passwd = $_POST['passwd']; //new line add
  18.  
  19. echo($passwd);
  20.  
  21. $stmt=$conn->prepare("SELECT password FROM user WHERE password=?");
  22.  
  23. $stmt->execute(['passwd']);
  24.  
  25. $stmt->setFetchMode(PDO::FETCH_CLASS,'password');
  26.  
  27. $result=$stmt->fetch();
  28.  
  29. if($result&&password_verify($_POST['passwd'],$result['password']))
  30.  
  31. //comparing
  32.  
  33. { echo("True");
  34.  
  35. }
  36.  
  37. else
  38.  
  39. {
  40.  
  41. echo("False");
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement