当$id是abc@ab 时,它返回true。这正如预期的那样!
但是当$id是1234567 时,它返回false。这并不 像预期的那样!
我的数据库:
+----+---------+---------+-----------+
| Id | Email | Mobile | Password |
+----+---------+---------+-----------+
| 15 | abc@a.b | 1234567 |$2y$10$ix..|
+----+---------+---------+-----------+
我的代码:
public function customer_login($id,$password)
{
try
{
$stmt = $this->conn->prepare("SELECT * FROM customer WHERE Email=:_email");
$stmt->execute(array(":_email"=>$id));
$userRow=$stmt->fetch(PDO::FETCH_ASSOC);
$id = $userRow['Id'];
$stmtM = $this->conn->prepare("SELECT * FROM customer WHERE Mobile=:_mobile");
$stmtM->execute(array(":_mobile"=>$id));
$userRowM=$stmtM->fetch(PDO::FETCH_ASSOC);
$id = $userRowM['Id'];
if (password_verify($password, $userRow['Password']) || password_verify($password, $userRowM['Password']))
{
$_SESSION['customer'] = $id;
return true;
}
else
{
return false;
}
}
catch(PDOException $ex)
{
echo $ex->getMessage();
}
}
当$id是abc@ab 时,它返回true。这正如预期的那样!
但是当$id是1234567 时,它返回false。这并不 像预期的那样!
回首忆惘然
GCT1015