SQL 입문에 취약한 다음 코드로 몇 년간 자습서를 작성 했으므로 끝내야합니다.PHP injector에 취약한 PHP 코드
누구나 나에게 설명 할 수 있습니까 mysql_real_escape_strinng()
? 현재 방탄 방법입니까?
//Function to sanitize values received from the form. Prevents SQL injection
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
//Sanitize the POST values
$usr = $_SESSION['usr'];
$live = (isset($_POST['live']))?1:0;
$created = date("F j, Y, g:i a",time()+60*60);
$title= clean($_POST['title']);
$content = clean($_POST['content']);
//Create INSERT query
$qry = "INSERT INTO news(usr, live, created, title, content) VALUES('$usr', '$live', '$created', '$title', '$content') ";
$result = @mysql_query($qry);
가능한 중복 http://stackoverflow.com/ 질문/60174/best-way-to-stop-sql-injection-in-php) –
+1 좋은 코드. '$ _SESSION [ 'usr']'이 이미 새 니타 이징되었다는 것을 전제로하면 괜찮습니다! – TMS