login.aspx.cs

(完整代码) 1KB

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using dao;
public partial class login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["yhid"] != null)
            {
                Session.Abandon();
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string yhm = this.yhm.Text;
        string mm = this.mm.Text;
        int row = 0;
        if (yhm.Length == 0 || mm.Length == 0)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('用户名和密码不能为空!');</script>");
            return;
        }
        string sql = "select * from yonghu where yhm='" + yhm + "' and mm='" + mm + "'";
        DataTable dt = DBHelper.GetDataSet(sql);
        if (dt.Rows.Count > 0)
        {
            //是在线用户
            Session["yhm"] = yhm; //保存用户ID
            Session["mm"] = mm; //保存用户登录名
       Session["qx"] = dt.Rows[0]["qx"].ToString();  //保存用户权限
            Session["id"] = dt.Rows[0]["yhid"].ToString();  //保存用户登录名
            //Response.Redirect(Request.CurrentExecutionFilePath); //跳转到当前请求的虚拟路径
            //  Response.Redirect("main.aspx"); //跳转到当前请求的虚拟路径

            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('登录成功!');location.href='index.html';</script>");
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('用户名或密码错误!');</script>");
            return;
        }
    }
}

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

AI 解读

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

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