日期:2014-05-18  浏览次数:20460 次

急。。。新手上路请大家帮忙 登录代码怎么写
用户名: txtUsername
密码: txtPassword
验证码: txt3

登录(btn1) 重置(btn2)


------解决方案--------------------
string strname = Request.Form["username"].ToString().Trim();
string strpass = FormsAuthentication.HashPasswordForStoringInConfigFile(Request.Form["password"].ToString().Trim(), "MD5").Substring(10, 8);
string strcode = Request.Form["yzm"].ToString().Trim();
//这是参数化查询,建议大家养成这种习惯,可防SQL注入
//需要注意的是,参数必须与SQL语句中出现的参数顺序保持一致,不能出现颠倒的情况
string[,] para = { { "@username", strname }, { "@password", strpass } };
string strsql = "select count(users_id) from Ql_users where users_name=@username and users_pwd=@password";
string[,] paraid = { { "@username", strname } };


int iuser = int.Parse(haitian.Data.ExecuteScalar(strsql, para).ToString());
try
{
if (strcode != Session["verifycode"].ToString())
{
Page.RegisterStartupScript("", "<script>alert('验证码不正确!');javascript:history.go(-1)</script>");
return;
}
//如果用户存在转入到管理界面,并保存用户的信息
if (iuser > 0)
{

Session["name"] = strname.ToString().Trim();
 


}
else
{
Page.RegisterStartupScript("", "<script>alert('用户名,密码不正确!')</script>");
}
}
catch (System.Exception ex)
{
Response.Write(ex.ToString());
}
------解决方案--------------------

if (!string.IsNullOrEmpty(email.Text) ||
!string.IsNullOrEmpty(password.Text) ||
!string.IsNullOrEmpty(userName.Text)
)
{
if (!ExistEmail(email.Text))
{
if (!ExistName(userName.Text))
{

if (userHelper.Register(email.Text, password.Text, userName.Text))
{
MessageBox.ShowAndRedirect(this, "注册成功", url);
}
else
{
MessageBox.Show(this, "注册失败,请联系管理员");
}
}
else
{
MessageBox.Show(this, "用户名已存在");
}
}
else
{
MessageBox.Show(this, "邮箱已存在");
}
}

lz如果想要界面或者js判断登陆的,都有,加我Q568814139