我想知道如何编辑我的代码以加密用户密码。目前,用户填写一个 HTML 表单,该表单customerRegister.php
在提交查询之前要经过一系列验证。
客户注册.php
registerUser($_POST['firstName'], $_POST['lastName'], $_POST['username'], $_POST['houseNo'], $_POST['StreetName'], $_POST['town'], $_POST['postCode'], $_POST['emailAddress'], $_POST['phoneNumber'], $_POST['password'], $_POST['conPassword'],$_POST['carRegistration'],$_POST['carMake'],$_POST['carModel'],$_POST['carYear'],$_POST['carEngineSize'],$_POST['carFuel']);
function registerUser($firstName, $lastName, $username, $houseNo, $streetName, $town, $postCode, $emailAddress, $phoneNumber, $password, $conPassword, $registration, $carMake, $carModel, $carYear, $carEngineSize, $carFuel) {
$registerQuery = new UserLoginQueries();
/********************************
SERIES OF VALIDATIONS
********************************/
$registerQuery->insertUser($firstName, $lastName, $username, $houseNo, $streetName, $town, $postCode, $emailAddress, $phoneNumber, $password);
然后将这些详细信息传递给执行查询的 userLoginQueries.php。
用户登录查询.php
public function insertUser($custFirstName, $custLastName, $username, $houseNo, $streetName, $town, $postCode, $email, $number, $pass) {
$sth = $this->conn->prepare("INSERT INTO `customer`(`CustFirstName`, `CustLastName`, `HouseNo`, `StreetName`, `Town`, `PostCode`, `EmailAddress`, `PhoneNumber`, `Username`, `Password`) VALUES (?,?,?,?,?,?,?,?,?,?)");
$sth->bindValue (1, $custFirstName);
$sth->bindValue (2, $custLastName);
$sth->bindValue (3, $houseNo);
$sth->bindValue (4, $streetName);
$sth->bindValue (5, $town);
$sth->bindValue (6, $postCode);
$sth->bindValue (7, $email);
$sth->bindValue (8, $number);
$sth->bindValue (9, $username);
$sth->bindValue (10, $pass);
$sth->execute();
}
当用户输入他们的登录信息时,将运行以下查询:
public function queryLogin($username, $password) {
$sth = $this->conn->prepare("SELECT * FROM customer WHERE Username = ? AND Password = ? AND UserType = 'Customer'");
$sth->bindValue (1, $username);
$sth->bindValue (2, $password);
$sth->execute();
$count = $sth->rowCount();
return $count;
}
如何修改我的代码以加密用户密码?