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

動態留言功能調整

動態留言功能調整

guestmap55 最近改進了朋友動態的發文方式.... 一開始在功能方面加上了googlemap...

關於資安防護

關於資安防護

一直以來我都不敢寫跟資安有關的文章..對我來說...資安一直是一個課題..XSS...CSRF......

CentOS 5.2 使用 YUM 將 PHP 5.1.6 更新到 5.2.6

CentOS 5.2 使用 ...

CentOS 5. 版內建的 PHP 版本為 5..,甚至於 5. 版仍舊是 5.. 版本。 基於系...

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