PrivateSub Page_Load()Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
If Page.IsPostBack Then Try If TextBox2.Text = checkuser("user_pwd") Then FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, True)
EndIf Catch ex As Exception
Response.Write("验证失败,Please Check")
EndTry EndIf End Sub PublicFunction checkuser()Function checkuser() As SqlDataReader
Dim conn AsNew SqlConnection("data source=localhost;initial catalog=db_xiannet;user id=sa;pwd=SC")
Dim com AsNew SqlCommand("select * from tb_xiannet_user where user_name='"& TextBox1.Text &"' and user_pwd='"& TextBox2.Text &"'", conn)
Dim reader As SqlDataReader
conn.Open()
Try reader = com.ExecuteReader
reader.Read()
Catch ex As Exception
EndTry Return reader
End Function
此为数据库中的密码是经过MD5加密的
PrivateSub Page_Load()Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
If Page.IsPostBack Then Try If FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox2.Text, "md5") = checkuser("user_pwd") Then FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, True)
EndIf Catch ex As Exception
Response.Write("验证失败,Please Check")
EndTry EndIf End Sub PublicFunction checkuser()Function checkuser() As SqlDataReader
Dim conn AsNew SqlConnection("data source=localhost;initial catalog=db_xiannet;user id=sa;pwd=SC")
Dim com AsNew SqlCommand("select * from tb_xiannet_user where user_name='"& TextBox1.Text &"' and user_pwd='"& FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox2.Text, "md5") &"'", conn)
Dim reader As SqlDataReader
conn.Open()
Try reader = com.ExecuteReader
reader.Read()
Catch ex As Exception
EndTry Return reader
End Function
posted on
2005-03-07 18:06雪无止境
阅读(259)
评论(0)
编辑收藏举报