password_hash and verify problem | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

password_hash and verify problem

For some reason, this isn't supposed to print henlo yet but it does, anyways, here's my code: <?php $AdminPassword=password_hash("hi", PASSWORD_DEFAULT); if ($_POST["String"]==password_verify($_POST["String"], $AdminPassword)) { echo 'henlo'; } ?> <html> <head> <title> Password </title> </head> <body> <div id="container"> <div id="card-panel black-text"> <form action="" method="POST" class="modal-content"> <center><label for="String">Enter Password </label><br><input type="password" placeholder="Password" name="String" required><br> <input type="submit" type="submit" value="Check"> </form> </div> </div> </body> </html>

26th Feb 2018, 7:50 PM
epic gamer
epic gamer - avatar
3 Answers
+ 3
password_verify() returns a boolean
26th Feb 2018, 8:12 PM
Toni Isotalo
Toni Isotalo - avatar
+ 2
Post it in code play ground and then post ur code.
26th Feb 2018, 7:53 PM
RR2001
RR2001 - avatar
+ 1
password_verify returns a boolean. you should just be able to do if(password_verify($_POST["String"], $AdminPassword)) { ... ... }
2nd Mar 2018, 2:42 AM
Ben Allen (Njinx)
Ben Allen (Njinx) - avatar