


PHP的數(shù)據(jù)過濾防注入的方法
添加時(shí)間:2014-7-17 17:48:32
添加:
思海網(wǎng)絡(luò)
插入數(shù)據(jù)時(shí)用addslashes()就好了,其他的再根據(jù)需要進(jìn)行處理。
不管magic_quotes_gpc是On還是Off,添加數(shù)據(jù)時(shí)都用addslashes(),當(dāng)On時(shí),必須使用stripslashes(),Off時(shí)則不能用stripslashes()。
//提交數(shù)據(jù),或者變量準(zhǔn)備:
$Content=addslashes("這里面是數(shù)據(jù),不管有沒單引號(hào)或者還是變量");
//插入數(shù)據(jù)到數(shù)據(jù)庫(kù),代碼省略
//開始顯示數(shù)據(jù)
$Content="從數(shù)據(jù)庫(kù)讀取的數(shù)據(jù)";
不管magic_quotes_gpc是On還是Off,添加數(shù)據(jù)時(shí)都用addslashes(),當(dāng)On時(shí),必須使用stripslashes(),Off時(shí)則不能用stripslashes()。
//提交數(shù)據(jù),或者變量準(zhǔn)備:
$Content=addslashes("這里面是數(shù)據(jù),不管有沒單引號(hào)或者還是變量");
//插入數(shù)據(jù)到數(shù)據(jù)庫(kù),代碼省略
//開始顯示數(shù)據(jù)
$Content="從數(shù)據(jù)庫(kù)讀取的數(shù)據(jù)";
if(get_magic_quotes_gpc()){ $Content=stripslashes($Content); }
關(guān)鍵字:PHP、數(shù)據(jù)庫(kù)、過濾、注入
新文章:
- CentOS7下圖形配置網(wǎng)絡(luò)的方法
- CentOS 7如何添加刪除用戶
- 如何解決centos7雙系統(tǒng)后丟失windows啟動(dòng)項(xiàng)
- CentOS單網(wǎng)卡如何批量添加不同IP段
- CentOS下iconv命令的介紹
- Centos7 SSH密鑰登陸及密碼密鑰雙重驗(yàn)證詳解
- CentOS 7.1添加刪除用戶的方法
- CentOS查找/掃描局域網(wǎng)打印機(jī)IP講解
- CentOS7使用hostapd實(shí)現(xiàn)無AP模式的詳解
- su命令不能切換root的解決方法
- 解決VMware下CentOS7網(wǎng)絡(luò)重啟出錯(cuò)
- 解決Centos7雙系統(tǒng)后丟失windows啟動(dòng)項(xiàng)
- CentOS下如何避免文件覆蓋
- CentOS7和CentOS6系統(tǒng)有什么不同呢
- Centos 6.6默認(rèn)iptable規(guī)則詳解