判定用户登录,然后分别跳转到对应的页面
我有三个用户,三个用户数据库用了一个DropDownList 下面是用户名 密码 和验证码 用同一个登录框,然后登录后分别跳转到对应的页面,
程序代码: protected void Button1_Click1(object sender, EventArgs e)
{
string wbbh = this.wbbh.Value.ToString().Trim();
string userpass = FormsAuthentication.HashPasswordForStoringInConfigFile(this.pass.Value.ToString().Trim(), "MD5");
string verify = this.VerifyCode.Value.ToString().Trim();
if (verify != Session["verifycode"].ToString())
{
Response.Write("<script>alert('验证码不正确!');</script>");
return;
}
else
{
SqlConnection MyConn = new SqlConnection(ConfigurationManager.AppSettings["conStr"].ToString());
SqlCommand MyCommand = new SqlCommand();
MyCommand.Connection = MyConn;
MyConn.Open();
= "select * from wbreg where wbbh='" + wbbh + "'and apass='" + userpass + "'";
try
{
SqlDataReader MyReader = MyCommand.ExecuteReader();
if (MyReader.HasRows)
{
while (MyReader.Read())
{
Session["wbbh"] = wbbh ;
string sUrl = "Loginsuccess.aspx?id=" + wbbh ;
Response.Redirect(sUrl);
Response.Redirect("Loginsuccess.aspx");
}
}
else
{
Response.Write("<script>alert('登陆失败,请检查你的用户名和密码。');</script>");
}
MyReader.Close();
}
catch
{
Response.Write("<script>alert('请确定你的用户名或密码是否正确!');</script>");
}
MyConn.Close();
}
}这是我就一个用户的时候弄的,
麻烦各位大侠帮我把代码弄出来
在此谢谢大家了
[ 本帖最后由 njyf2008 于 2009-8-11 16:05 编辑 ]









