login.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.Sql;
using System.Data.SqlClient;
//该源码下载自www.51aspx.com(51aspx.com)

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string strconn = ConfigurationManager.AppSettings["dsn"];
        //连接本地计算机的LMS数据库
        SqlConnection cn = new SqlConnection(strconn);
        cn.Open();
        //构造SQL语句,该语句在Users表中检查用户名和密码是否正确
        string mysql = "select * from  yhxx where yonghuname='" + TextBox1.Text + "'and mima='" + TextBox2.Text + "'";
        //创建Command对象
        SqlCommand cm = new SqlCommand(mysql, cn);
        //执行ExecuteReader ()方法
        SqlDataReader dr = cm.ExecuteReader();
        if (dr.Read())
        {
            //保存当前用户名及用户权限
            Session["uid"] = dr["yonghuID"].ToString();
            Session["leibie"] = RadioButtonList1.SelectedItem.Text;
     
            Response.Redirect("main.aspx");
        }
        else
        {
            this.TextBox1.Text = "";
            this.TextBox2.Text = "";

        }
        //关闭连接
        cn.Close();
    }
}

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

AI 解读

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

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