私は攻撃の保護を注入してDBに挿入しようとしています。私はw3schoolsのいくつかの例を見つけましたが、それは私にとっては役に立ちません。接続は正しいですし、動作します。私はSQLとプログラミングの新機能として、そのインサートの何が問題なのか分かりません。どうか誰でも助けてくれますか?どうもありがとう。挿入するためのDBにインジェクション攻撃防御を挿入する
マイPHP:データベースAPIの混合している
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "dbname";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "<p>Connected successfully</p>";
$From = $_GET['From'];
$To = $_GET['To'];
$Type = $_GET['Type'];
$text = $_GET['text'];
$stmt = $conn->prepare("INSERT INTO orders (from_lang, to_lang, tex)
VALUES (:fr, :to, :tex)");
$stmt->bindParam(':fr', $From);
$stmt->bindParam(':to', $To);
$stmt->bindParam(':tex', $text);
$stmt->execute();
?>
mysqliをPDOと混合する。 'bindParam'はpdoで使用され、bind_paramはmysqliで使用されます。 – Saty
[PDOを使用する場合は、すべての道を行く](http://jayblanchard.net/demystifying_php_pdo.html) –
私は使いたいmysqli。私は 'bindParam'を' bind_param'に変更しましたが、それでも動作しません。 –