62,073
社区成员
发帖
与我相关
我的任务
分享
username = Request.QueryString["username"];
password = Request.QueryString["password"];
if (username == "" || password == "")
{
Response.Redirect("index.aspx");
}
string sql = "select Username from member where Username='"+username+"'";
SqlConnection con = new SqlConnection(connstr);
con.Open();
SqlCommand com = new SqlCommand(sql,con);
SqlDataReader read = com.ExecuteReader();
if (read.Read())
{
username = read["Username"].ToString();
read.Close();
string pwd1 = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5"); //ASCIIEncoding.ASCII.GetString(HashMD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(password)));
string strsql = "Select Active, Valid, LoginTime, SCCPoint From member where Username = '" +username + "' and Password = '" +pwd1+ "'";
com = new SqlCommand(strsql,con);
read = com.ExecuteReader();
if (read.Read())
{
string active = read["Active"].ToString();
string valid = read["Valid"].ToString();
if (active == "True")
{
if (valid == "True")
{
if (read["LoginTime"].ToString() == DateTime.Now.ToString())
{
SCCPoint_Increase = 1;
}
else
{
SCCPoint_Increase = 0;
}
string strupdate = "Update member Set LoginTime ='" + DateTime.Now.ToString() + "', LoginIP = '" + Context.Request.UserHostAddress.ToString() + "', SCCPoint = SCCPoint + '" + SCCPoint_Increase+"' Where Username = '" + username + "'";
com = new SqlCommand(strupdate, con);
read.Close();
if (com.ExecuteNonQuery() > 0)
{
HttpCookie cookie = new HttpCookie("userCookie");
cookie.Values.Add("userName", username);
cookie.Values.Add("userPwd", pwd1);
//cookie.Expires = DateTime.Now.AddHours(3);
Response.AppendCookie(cookie);
con.Close();
Response.Redirect("./User/surveycenter.aspx");
}
}
else
{
con.Close();
Session["message"] = "您的账户存在问题,通常是存在多账户情况。多账户包括:1、一个自然人注册(或使用)一个以上的账户;2、一个家庭注册(或使用)一个以上的账户;3、一个办公室(宿舍等)使用相同IP注册(或使用)一个以上的账户;4、同一台计算机上注册(或使用)一个以上的账户。请联系管理员,注意信中包含您的会员名,且不要用 21cn.com/sina.com/sohu.com/tom.com 的信箱来信,或访问论坛 <a href='http://bbs.surveys.com.cn'>http://bbs.surveys.com.cn</a> 提问";
Response.Redirect("fail.aspx");
}
}
else
{
con.Close();
Session["message"] = "您的账户未激活,请您激活账户后登陆";
Response.Redirect("fail.aspx");
}
}
else
{
con.Close();
Session["message"] = "密码错误,请重新输入";
Response.Redirect("fail.aspx");
}
}
else
{
con.Close();
Session["message"] = "没有此用户名,请您注册后登陆";
Response.Redirect("fail.aspx");
}