login.aspx.cs

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            txtUserName.Text = Common.GetCookie("UserName");
        }
    }

    /// <summary>
    /// 登录
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        //验证非空
        if (txtUserName.Text == "" || txtUserPwd.Text == "")
        {
            lblTip.Visible = true;
            return;
        }

        DataSet ds = SqlHelper.ExecuteforDataSet("select * from admin where lname='" + txtUserName.Text + "' and pwd='" + txtUserPwd.Text + "'");

        //判断用户是否存在
        if (ds.Tables[0].Rows.Count > 0)
        {
            DataRow dr = ds.Tables[0].Rows[0];

            //把用户信息存入到Session
            Session["UserNo"] =  dr["aid"].ToString();
            Session["UserName"] = dr["lname"].ToString();
            Session["UserRole"] = dr["flag"].ToString()=="1"? "管理员" : "普通用户";

            //写入Cookies
            if (cbRememberId.Checked)
            {
                Common.WriteCookie("UserName", txtUserName.Text, 14400);
            }
            else
            {
                Common.WriteCookie("UserName", txtUserName.Text, -14400);
            }

            //跳转到后台            
            Response.Redirect("index.aspx");
        }
        else
        {
            lblTip.Text = "用户名或密码错误!";
            return;
后面还有 3 行代码,购买后查看完整代码

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

AI 解读 AI

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

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