字符串$ title只能是小寫字母數字或符號「 - 」。
在這種情況下,下列哪種方法可以有效防禦安全漏洞?
$title=$_GET["title"];
$title = strtolower(preg_replace("/[^a-z0-9\-]+/i", "-", $title));
< mysql query using $title goes here >
OR
$title=$_GET["title"];
$title = mysql_real_escape_string($title);
< mysql query using $title goes here >
如果你喜歡用愚蠢和過時的mysql_ *功能,那麼你必須用'mysql_real_escape_string' *** ***總是和*** ***所有值。 – mario