Reputation: 65
my password_verify function doesn't return anything and yet i think my code is OK,i tried removing the character escapes but still same results,please help this is my code
<?php
if (isset($_POST['submit'])) {
include_once 'db.php';
$uname = stripcslashes($_POST['username']);
$pass = stripcslashes($_POST['userpassword']);
$uname = mysqli_real_escape_string($conn, $_POST['username']);
$pass = mysqli_real_escape_string($conn, $_POST['userpassword']);
//check if input characters are valid
if (!preg_match("/^[a-zA-Z0-9]*$/",$uname) || !preg_match("/^[a-zA- Z0-9]*$/",$pass)) {
header("Location: ../index.php?signin=invalidwords");
exit();
}else {
//validate username n pwd
$sql = "SELECT * FROM loginAcc WHERE position='$uname'";
$result = mysqli_query($conn,$sql);
$row = mysqli_fetch_array($result,MYSQLI_ASSOC);
$count = mysqli_num_rows($result);
$hashedpwd = $row['userpassword'];
$pw = password_verify($pass,$hashedpwd);
echo $pass."<br />";
echo $hashedpwd."<br />";
echo $pw;
}
}else{
header("Location: ../login.php");
exit();
}
Upvotes: 1
Views: 81
Reputation: 1005
password_verify()
return bool value, and in case your $pw is false, then echo $pw
will print nothing.
Try to test 2 cases with correct and incorrect password.
Upvotes: 1