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

利用 css 讓 ul 置中呈現

利用 css 讓 ul 置中...

以前寫網站...總是喜歡用Table 包住內容.. 而隨著時空的轉換...現在大都用div..或者....

讓圖片上傳前先產生預覽

讓圖片上傳前先產生預覽

專案需要,上傳圖片至網站時先產生預覽圖~ 參考了stackoverflow.com裡討論的的方式

新舊交替,使用phpmyadm出現1064 error in CREATE TABLE … TYPEMYISAM錯誤

新舊交替,使用phpmyad...

sql55 系統移機的過程中,最重要的環節....我想...莫過於是系統的環境了....。 這次在協...

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