Login.aspx.cs

(完整代码) 1KB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
namespace MyMD5
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        //登陆按钮
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            //实例化公共类对象
            DB db = new DB();
            string userName = txtUserName.Text.Trim();
            string passWord = db.MyMD5(txtPwd.Text.Trim());//对密码进行Md5加密
            string num = txtValidateNum.Text.Trim();
            if (Session["validateNum"].ToString() == num.ToUpper())
            {
                //获取用户信息
                SqlDataReader dr = db.reDr("Select * from tb_User where UserName='" + userName + "' and UserPwd='" + passWord + "'");
                dr.Read();
                if (dr.HasRows)//通过dr中是否包含行判断用户是否通过身份验证
                {
                    Session["UserID"] = dr.GetValue(0);//将用户ID存入 Session["UserID"]中
                    //Session["Role"] = dr.GetValue(4);//将用户权限存入Session["Role"]中
                    Response.Write("<script>alert('登录成功!')</script>");
                }
                else
                {
                    Response.Write("<script>alert('登陆失败!请返回查找原因');location='Login.aspx'</script>");
                }
                dr.Close();
            }
            else 
            {
                Response.Write("<script>alert('验证码输入错误');location='Login.aspx'</script>");
            }
        }
        //注册
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            Response.Redirect("Register.aspx");
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。