[英]Secure way to insert and retrieve data to and from MySQL
好吧,我想知道一些有關PHP和MySQL的技巧。
當我從用戶那里獲取數據時,我將使用以下驗證:
mysql_real_escape_string()
or
htmlentities()
or
trim()
從用戶那里獲取數據的安全方法嗎?
從Mysql數據庫檢索數據的最佳方法是什么? 我使用了nl2br()
,但是如果我提交I'm here
那么它表明I\\'m here
。 它應該表明I'm here
。 我不知道什么是正確的方法。
將數據插入數據庫時,將使用mysql_real_escape_string
; 不是htmlentities
。 甚至更好的MySQLi- 甚至更好的 PDO 。
當從數據庫中輸出可能不安全的數據時,您可能會使用htmlentities
。
要停止斜杠,請關閉魔術引號 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.