結果は出力されません。理由がわからない。すべてがきちんとコメントされています
エラー表示も構文冒涜も表示されず、結果が出力されません。ただし、値がフォームによってこの処理中のphpページに渡されることは知っているので、エラーはそこにはありません。DBでは、「company」を除くすべてのフィールドを暗号化しました。したがって、結果をフェッチして戻すことで、これが機能するかどうかを確認したいと思います。
// 1. Creating a new server connection
$db = new mysqli('localhost', 'root', '', 'developers');
if ($db->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}
// 2, Creating statement object
$stmt = $db->stmt_init();
// 3, Creating a prepared statement
if($stmt->prepare("SELECT company FROM accesoweb WHERE username = AES_DECRYPT(?, 'salt')")) {
//4. Binding the variable to replace the ?
$stmt->bind_param('s', $username);
printf("Error: %d.\n", $stmt->errno);
// 5. Executing query
$stmt->execute();
// 6. Binding the result columns to variables
$stmt->bind_result($company);
// 7. Fetching the result of the query
while($stmt->fetch()) {
echo $company;
}
// 8. Closing the statement object
$stmt->close();
// 9. Closing the connection
$mysqli->close();
}
MySQLに含めた挿入コードは次のとおりです。
INSERT INTO accesoweb (company, username,email,password)
VALUES
('hola',
AES_ENCRYPT('maria','salt'),
AES_ENCRYPT('sumail','salt'),
AES_ENCRYPT('password',' salt')
);
したがって、上の行(実際には、「会社」は、PHPコードを介して回復しようとしているものです)