用戶登陸驗證

if (Page.IsValid)
        {
            if (String.Compare(Request.Cookies["CheckCode"].Value, txtcode.Text.ToUpper(), true) != 0)
            {

                Response.Write("<script>alert('验证码错误,请输入正确的验证码!!');window.location.reload('login.aspx')</script>"); return;

            }
            string password = FormsAuthentication.HashPasswordForStoringInConfigFile(TBXuserpass.Text, "md5");
            OleDbConnection conn = dbcon.createconnection();
            conn.Open();
            OleDbParameter txtusername = new OleDbParameter("@username", OleDbType.VarChar, 30);
            txtusername.Value = TBXusername.Text;
            OleDbParameter txtuserpass = new OleDbParameter("@userpass", OleDbType.VarChar, 40);
            txtuserpass.Value = password;
            string strSql = "select * from sysenter where enteru=@username and enterp=@userpass";
            OleDbCommand mycommand = new OleDbCommand(strSql, conn);
            mycommand.Parameters.Add(txtusername);
            mycommand.Parameters.Add(txtuserpass);
            OleDbDataReader rs = mycommand.ExecuteReader();
            if (rs.Read())
            {

                if (password == rs["enterp"].ToString())
                {
                    Session.Timeout = 120;
                    Session["enteruser"] = TBXusername.Text;
                    Session["flag"] = rs["flag"].ToString();
                    conn.Close();
                    Response.Redirect("admin_main.html");
                }
                else
                {
                    conn.Close();
                    Labmsg.Text = "对不起,您输入的密码有误!";
                    return;
                }
            }
            else
            {
                conn.Close();
                Labmsg.Text = "对不起,帐号或密码错误!";
                return;
            }

        } 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值