<% If Request("UserName")<>"" And Request("Pass")<>"" Then Dim cnn,rec,strSQL Set cnn=Server.CreateObject("ADODB.Connection") With cnn .ConnectionString=Application("Conn") .Open
''''利用使用者输入的资料来组合 SQL 语法 strSQL="SELECT * FROM tblUser WHERE UserName=''''" & _ Request("UserName") & "'''' AND Password=''''" & Request("Pass") & "''''" ''''直接交给 SQL Server 执行,这是最危险的地方 Set rec=.Execute(strSQL) End With If NOT rec.EOF Then Session("UserName")=Request("UserName") Response.Write "欢迎光临 " & Request("UserName") Else Response.Write "您的帐号/密码输入错误" End If
Else %> <Form action="login.asp"> 使用者名称:<Input Name="UserName"><P> 密码:<Input Name="Pass" > <P> <Input type="submit" Value="确定"> </Form> <% End If %>