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

Responsive Web Design使用CSS3的Media Queries進行自適應網頁設計

Responsive Web...

智慧型手持裝置(手機、平板)已是非常普及的日常生活必需品。 所以現在,在開發系統時客戶都會詢問是否支...

分享到各社群的方式

分享到各社群的方式

每次在寫網站系統時..客戶總會要求希望他們的網站可以有分享到社群網站的功能... 所以把一些常用的方...

解決FB分享帶參數問題

解決FB分享帶參數問題

又到了FB分享連結的時間了,沒辦法FB太紅...@@... 一般來說如果是以FB的分享網址做分享的方...

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