我从别的地方抄来一段。NET的 登陆代码!
一直搞不清楚 Session覆值在着段代码什么地方写,如何写? 请各位高手指点, 谢谢! string userName=Request.Form["userName"].ToString();
string userPwd=Request.Form.Get("userPwd").ToString();
SqlConnection con=new SqlConnection("server=.;database=login;uid=sa;pwd=;");
con.Open();
SqlCommand cmd=new SqlCommand("select count(*) from login where userName='"+userName+"' and userPwd='"+userPwd+"'",con);
int count=Convert.ToInt32(cmd.ExecuteScalar());
if(count>0)
{
Response.Redirect("index_admin.aspx");
}
else
{
Response.Redirect("sb.htm");
}
一直搞不清楚 Session覆值在着段代码什么地方写,如何写? 请各位高手指点, 谢谢! string userName=Request.Form["userName"].ToString();
string userPwd=Request.Form.Get("userPwd").ToString();
SqlConnection con=new SqlConnection("server=.;database=login;uid=sa;pwd=;");
con.Open();
SqlCommand cmd=new SqlCommand("select count(*) from login where userName='"+userName+"' and userPwd='"+userPwd+"'",con);
int count=Convert.ToInt32(cmd.ExecuteScalar());
if(count>0)
{
Response.Redirect("index_admin.aspx");
}
else
{
Response.Redirect("sb.htm");
}
string userPwd=Request.Form.Get("userPwd").ToString();
SqlConnection con=new SqlConnection("server=.;database=login;uid=sa;pwd=;");
con.Open();
SqlCommand cmd=new SqlCommand("select count(*) from login where userName='"+userName+"' and userPwd='"+userPwd+"'",con);
int count=Convert.ToInt32(cmd.ExecuteScalar());
if(count>0)
{
///在这里写,用户已经可以登录了,就要记录session了,然后再跳转页面
Session["User_ID"] = "XXX";
Response.Redirect("index_admin.aspx");
}
else
{
Response.Redirect("sb.htm");
}
这位大哥说的对
{
Response.Redirect("index_admin.aspx");
}