$sel1 = mysql_query ("SELECT ID, name, locale, lastlogin, gender,
FROM USERS_TABLE
WHERE (name = '$user' OR email = '$user') AND pass = '$pass'");
$chk = mysql_fetch_array($sel1);
if (found one record)
then {allow the user to login}`
问题是尝试使用用户名admin');#“登录,然后您会发现您以用户admin身份登录! 问题询问sql注入中每个特殊字符的用途。 , ) ; # “
谢谢!
答案 0 :(得分:0)
此值:
admin');#
将在字符串" admin"之后终止SQL语句。并作为评论后对待一切。所以这个:
SELECT ID, name, locale, lastlogin, gender,
FROM USERS_TABLE
WHERE (name = '$user' OR email = '$user') AND pass = '$pass'
基本上变成了这个:
SELECT ID, name, locale, lastlogin, gender,
FROM USERS_TABLE
WHERE (name = 'admin')
找到一条记录,并且系统正在继续前进,将用户记录为'admin'
,因为查询已成功找到该记录。