I am write a simple web service for login process from .net. I am using nusoap php library for server side. In that server side I am hashing to given password and query it in database to check if there is such that hashed password. But in .net I am getting error that the response is text/html format while it waitings text/xml format. Error is password_hash function doesn't founden but this is php's built-in function. And I check that functions in seperate .php file and it works without error same for encrypting and decrypting(password_verify). So where am I going wrong in this situation?
This is my code;
function systemLogin($mycomplexlogin)
{
$result=NULL;
$conn=openConnection();
// Check connection
if ($conn->connect_error)
{
//return("Connection failed: " . $conn->connect_error);
return $result;
}
$EnterpriseId=mysqli_real_escape_string($conn,$mycomplexlogin["EnterpriseId"]);
$UserName=mysqli_real_escape_string($conn,$mycomplexlogin["UserName"]);
$Password=$mycomplexlogin["Password"];
$cost=10;
$hash="";
$hash=password_hash($Password, PASSWORD_BCRYPT, ["cost" => $cost]);
/* create a prepared statement */
$stmt = $conn->stmt_init();
// prepare and bind
if($stmt = $conn->prepare("SELECT * FROM mydatabase.USERS WHERE BINARY username=?"))
{
$stmt->bind_param("s", $UserName);
// execute query
$stmt->execute();
/* bind result variables */
$stmt->bind_result($resultId,$resultLastName,$resultFirstName,$resultAddress,$resultPosition,$resultManager,$resultUserName,$resultPass);
/* fetch value */
if($stmt->fetch())
{
if(password_verify($Password,$hash))
{
//date("Y-m-d H:i:s");
$token=date("Y-m-d H:i:s");
$result= array(
'Id' => $resultId,
'LastName'=>$resultLastName,
'FirstName' => $resultFirstName,
'Address'=>$resultAddress,
'Position'=>$resultPosition,
'Manager'=>$resultManager,
'Password' => $resultPass,
'UserName' => $resultUserName,
'Token' => $token
);
}
}
// close statement
$stmt->close();
}
mysqli_close($conn);
return $result;
}
Update# I found solution. In PHP-7 even if PHP's Manual Page says password_hash is inbuilt when I call it in nusoaps server side it doesn't recognize this function. When I call it seperate .php page it works. So at the end I download password hashing library from github and it works perfectly. I guess, I install PHP-7 wrongly or it is a bug.