Asp.net
登陆代码
private void btnLogin_Click(object sender, EventArgs e)
{
string sql = "SELECT userid FROM Users WHERE UserName = '" + txtUserName.Text.Replace("'","_") + "' AND UserPassword = '" + System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "md5") + "'";
// 使用上面类似的 SQL 语句向数据库执行查询,如果用户是合法的,将会返回数据。
if (...) // 根据条件判定用户是合法的
{
// 下面的语句告诉 .NET 发送一个验证 Cookie 给用户:
System.Web.Security.FormsAuthentication.SetAuthCookie(userid, false)
Response.Redirect("afterlogi
{
string sql = "SELECT userid FROM Users WHERE UserName = '" + txtUserName.Text.Replace("'","_") + "' AND UserPassword = '" + System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "md5") + "'";
// 使用上面类似的 SQL 语句向数据库执行查询,如果用户是合法的,将会返回数据。
if (...) // 根据条件判定用户是合法的
{
// 下面的语句告诉 .NET 发送一个验证 Cookie 给用户:
System.Web.Security.FormsAuthentication.SetAuthCookie(userid, false)
Response.Redirect("afterlogi