我正在閱讀關於表單安全性的文章,因爲我有一個用戶可以添加消息的表單。php表單安全性
我看,這是最好使用用strip_tags(),用htmlspecialchars()和nl2br()
別的地方說要用html_entity_decode()
我在我的網頁此代碼,將用戶輸入
<?php
$topicmessage = check_input($_POST['message']); //protect against SQLinjection
$topicmessage = strip_tags($topicmessage, "<p><a><span>");
$topicmessage = htmlspecialchars($topicmessage);
$topicmessage = nl2br($topicmessage);
?>
但是當我回聲消息,這一切都在同一行,看來,在休息已經被用strip_tags刪除而不是通過nl2br()
放回對我來說,這是有道理的,爲什麼它這樣做,因爲如果休息已被刪除,它如何知道把它放回(或做它)?
,無論如何,我在尋找一種方式,我可以保護我的形成被用來嘗試和黑客網站類似形式
-1不要使用mysql_real_escape();使用參數化查詢。 – 2010-08-13 16:00:29
我真的沒有看到使用mysql_real_escape()的危害。你的陳述有什麼理由嗎? – marekventur 2011-05-14 15:17:09