有一张表,三个字段,account,password,type。现在做登录页面,页面上
只是输入用户名和密码还有一个验证码,根据输入的用户名和密码到表中对比。如果type是A,就跳到A页,是B就跳到B页,是C就跳到C页,我贴一部分代码,麻烦大家帮我把type判断完成。谢谢了。
protected void imgbtnLogin_Click(object sender, ImageClickEventArgs e)
{
string userName = this.TxtUserName.Value;
string password = this.TxtPassword.Value;
if (userName != "" && password != "")
{
DataTable dt = DBHelper.GetDataSet("select * from employs where ACCOUNT='" + userName +
"' and password='" + password + "'");
if (dt.Rows[0][0].ToString() != "0")
{
//把登录用户保存到Session中
Session["user"] = dt.Rows[0]["ACCOUNT"].ToString();
//判断验证码是否符合
if (Session["VerifyChar"].ToString() == this.txtcode.Value)
{
//应该在此处判断type吧?麻烦大家了
{
Response.Redirect("Main.aspx");
}
}
}
else
{
Response.Write("<script>alert('登录失败,请重新登录!');location.href='index.aspx';</script>");
}
}
else
{
Response.Write("<script>alert('请输入用户名和密码!');location.href='index.aspx';</script>");
}
}