Loading...

在PHP裡面如何做到基本的SQL injection防禦?

Temperature: 0 °C

ChungChung
author_tools

資訊安全一直是很頭痛的問題....一直以來也在尋找最好的方式...

但在尋找的過程中...至少也得做基本的防範措施...

基本方式一 啟動magic_quotes_gpc

magic_quotes_gpc是PHP內建的防禦SQL injection的基本手段...

能夠自動去將所有透過GET、POST傳值的資訊進行處理,把一些符號(例如單引號、雙引號)加入轉譯符號(反斜線)...

藉此來避免SQL injection的問題發生....

不過magic_quotes_gpc有個缺點就是了,如果使用者傳入的資料並非是攻擊字串???

可是在開啟magic_quotes_gpc的情況下他仍然會進行處理

這時候就會導致使用者的輸入資料與原本的不同,因此是否要啟動magic_quotes_gpc就看你個人選擇......

啟動magic_quotes_gpc很簡單,開啟你的php.ini,然後搜尋「magic_quotes_gpc」

把magic_quotes_gpc=off改成magic_quotes_gpc=on

預設情況下是開啟的

參考資訊 http://php.net/manual/en/security.magicquotes.php

https://innstory.com/story-在PHP裡面如何做到基本的SQL_injection防禦-267
寫程式筆記

Prev
 回檳城走走之檳城美食炒粿條

Next
DIV區塊內文字左右對齊 

About the Author

Chung

我是chung
網路工作者
主業是網站系統開發建置
副業是做夢,寫故事
作品請參考/teme.biz
做夢請參考/innstory.com
聯絡/chung.teme@gmail.com

#有人用筆寫日記,有人用歲月寫日記,有人用照片寫日記,而我,用innstory寫日記。

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

Photoshop 曲線文字建置

Photoshop 曲線文字...

Photoshop一直都是很強悍的繪圖軟體。 裡頭的【鋼筆工具】,可以拉貝茲曲線的.... 我剛開始...

PDO連接Mysql方式 MVC上應用

PDO連接Mysql方式 M...

pexelsphoto5 將連結資料庫的方式加入model function connect() {...

PDO連接Mysql方式

PDO連接Mysql方式

pexelsphoto 最近因為源碼檢測的原因,才驚覺自己以前的系統撰寫的方式早已不再安全。 所以決...

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format