가 주입을위한 문자열을 확인하지, 당신은. 변수를 연결할되지 할 필요가
- 를 사용하여 문 준비.
에서 mysqli 추출물에 "예"모든
$name = $_GET['username'];
if ($stmt = $mysqli->prepare("SELECT password FROM tbl_users WHERE name=?")) {
// Bind a variable to the parameter as a string.
$stmt->bind_param("s", $name);
// Execute the statement.
$stmt->execute();
// Get the variables from the query.
$stmt->bind_result($pass);
// Fetch the data.
$stmt->fetch();
// Display the data.
printf("Password for user %s is %s\n", $name, $pass);
// Close the prepared statement.
$stmt->close();
}
읽기 : http://www.veracode.com/security/sql-injection
아이디어가에 대한 변수 '또는'또는 확인 인 경우, 그것은 하드 끊임없는 일이고 결국 PDO의 한 Statment를 사용하여 해결할 수 있습니다.
구체적으로 작성하십시오. SQL 인젝션이 준비된 문을 사용하지 못하도록 –
나는 그것을 막지 않도록 구체적으로 요구하지 않습니다. 제 생각과 똑같은 해결책을 찾을 수 있는지 묻습니다. 그래서 '와'같은 문자를 받아들이지 마라. –