1
html 做登录页面 login.aspx 的 cs 做逻辑验证
html 做登录页面 login.aspx 的 cs 做逻辑验证
<form action="login.aspx" method="get" name="baoge">
<TABLE id="Table1" height="184" cellSpacing="3" cellPadding="10" width="473" align="center"
<TABLE id="Table1" height="184" cellSpacing="3" cellPadding="10" width="473" align="center"
string username=Request.QueryString["username"].ToString();
string userpwd=Request.QueryString["userpwd"].ToString();
//先把密码加密
string jm=System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(userpwd,"md5");
//得到连接字符串
string dbPath=System.Configuration.ConfigurationSettings.AppSettings["lyb"];
//定义数据库连接字符串
string ACconnStr="Provider=Microsoft.Jet.OleDb.4.0;Data Source="+Server.MapPath(dbPath);
//创建数据库连接对象
OleDbConnection ACconn=new OleDbConnection(ACconnStr);
ACconn.Open();
OleDbCommand cmd=new OleDbCommand("select count(*) from admin where username='"+username+"' and userpwd='"+jm+"'",ACconn);
//又一种 登录 方法
int count=Convert.ToInt32(cmd.ExecuteScalar());
if(count>0)
{
Session["name"]=true;
Response.Redirect("admin_index.aspx");
}
else
{
Response.Redirect("fail.htm");
}
}
string userpwd=Request.QueryString["userpwd"].ToString();
//先把密码加密
string jm=System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(userpwd,"md5");
//得到连接字符串
string dbPath=System.Configuration.ConfigurationSettings.AppSettings["lyb"];
//定义数据库连接字符串
string ACconnStr="Provider=Microsoft.Jet.OleDb.4.0;Data Source="+Server.MapPath(dbPath);
//创建数据库连接对象
OleDbConnection ACconn=new OleDbConnection(ACconnStr);
ACconn.Open();
OleDbCommand cmd=new OleDbCommand("select count(*) from admin where username='"+username+"' and userpwd='"+jm+"'",ACconn);
//又一种 登录 方法
int count=Convert.ToInt32(cmd.ExecuteScalar());
if(count>0)
{
Session["name"]=true;
Response.Redirect("admin_index.aspx");
}
else
{
Response.Redirect("fail.htm");
}
}