CheckLogin.aspx.cs

(完整代码) 1KB

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class CheckLogin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string userName = this.TextBox1.Text;
        string userPwd = this.TextBox2.Text;
        SqlConnection conn = DB.getConnection();
        SqlCommand cmd = new SqlCommand("select count(*) from dbo.adminInfo where userName = '" + userName + "' and userPwd = '" + userPwd + "'", conn);
        conn.Open();
        int count = (int)cmd.ExecuteScalar();
        conn.Close();
        if (count > 0)
        {
            Session["Admin"] = userName;
            Response.Redirect("ShowInfo.aspx?info=" + Server.HtmlEncode("欢迎进入!!") + "");
        }
        else
        {
            Response.Redirect("ShowInfo.aspx?info="+ Server.HtmlEncode("对不起!用户名或者密码错误!!请确认后重新登陆!")+"");
        }
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        this.TextBox1.Text = "";
        this.TextBox2.Text = "";
        this.TextBox1.Focus();
    }
}

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

AI 解读

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

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