34,590
社区成员
发帖
与我相关
我的任务
分享
create table t_user
(
username varchar(20) primary key,
pwd varchar(20)
)
go
--示例数据:
insert into t_user(username,pwd)
select 'admin001','pwd001' union all
select 'admin002','pwd002' union all
select 'admin003','pwd003'
string username = textbox1.Text;
string pwd = textbox2.Text;
string sql = "select * from t_user where username ='" + username + "' and pwd = '" + pwd + "'";
...
//如果我分别输入 textbox1.Text = "1' or '1'='1'", textbox2.Text = "1' or '1'='1'" ,结果会如何呢,看看下面;
Response.Write(sql);
Response.End();
//输出结果如下:
select * from t_user where username ='1' or '1'='1' and pwd='1' or '1'='1'
string username = Replace(textbox1.Text,"'","");
string pwd = Replace(textbox2.Text,"'","');
string sql = "select * from t_user where username ='" + username + "' and pwd = '" + pwd + "'";
create procedure p_user_verify
@username varchar(20) = '',
@pwd varchar(20) = ''
as
set nocount on
if exists(select * from t_user where username = @username and pwd = @pwd )
return 1 -- return 1表示通过验证
else
return 0 -- return 0表示验证失败
go