用户名和密码未在数据库中更新

时间:2019-03-16 05:05:54

标签: php mysqli

我已经使用API​​登录页面,并且我使用postman发布的用户名和密码可以正常工作,但是在MySql数据库中未更新。该怎么办。 API

private function loginInsert(){
if($this->get_request_method() != "POST"){
  $this->response('', 406);
}

$username = $this->_request['username'];
$password = $this->_request['password'];

$password = password_hash($pass, PASSWORD_BCRYPT);
//$password = $password;  
$insertQuery = "INSERT INTO ADMIN(`username`, `password`) VALUES('$username', '$password')";
//$insertQuery = "SELECT * FROM usertable"
$insert = $this->mysqli->query($insertQuery) or die($this->mysqli->error.__LINE__);

if($insert){
 $result = array('status' => 'success', 'msg' => 'Logged in Successfully.');
}
else{
 $result = array('status' => 'failure', 'msg' => 'Login Failure.');
}

$this->response($this->json($result), 200);

}

1 个答案:

答案 0 :(得分:0)

您需要在此行中将$ pass更改为$ password: $ password = password_hash($ pass,PASSWORD_BCRYPT);