2012-07-04 63 views
0

祝大家好日子,抱歉提出這樣一個原始問題......但我無法回答! 我們必須輸入字段: 登錄 密碼mysql查詢與安全注射?

,所得到的MySQL

SELECT user.Ident,user.fname,user.lname FROM t_users爲用戶WHERE user.login =:登錄和用戶.pass =:密碼和user.status = 0

我不是黑客,我從來沒有使用mysql注射自己...所以我不能說這是安全的...因爲設置登錄到「'OR 1;#」將不起作用。

EDIT 1

如果我輸入 登錄= 「」 OR 1;#」 口令= '52352352' 我得到這個

Error Number: 1064 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' and user.pass='a32d2f2e60c1757c53cfbc3086d9ecc1' and user.status=0' at line 8

編輯2 問題已關閉,謝謝您的回答!

+0

嘗試,你在查詢中使用它們之前打印變量的值。是「狀態」字符串字段? – manurajhada

+0

是你的密碼在這種情況下加密你選擇應該像'select * from tableName where login ='login'and password = md5('password')' –

+0

@Elmor問題已關閉?不,只有當你接受答案時,即使這樣也可以進一步回答。 – glglgl

回答

2

user.login= = :login中刪除等於(==)的雙倍。 Sql與單個等於(=)比較。

編輯: 試試吧..

SELECT user.Ident, user.fname, user.lname FROM t_users as user 
WHERE user.login=:login and user.pass=:password and user.status='0'; 
+0

mistype ...編輯 – Elmor

+0

剛剛編輯。現在試試。 – manurajhada

+0

我沒有一次指定它,但是:login&:password是放置適當字段的輸入的地方。 – Elmor