UserLogin.aspx.cs

(开头部分) 2KB

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

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 UserLogin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.Cookies["memberinfo"] != null)
            {
                JavaScriptHelper.AlertAndRedirect("您已经登录。", "usermain.aspx");
                return;
            }
        }
    }

    /// <summary>
    /// 登录
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        string username = txtLoginUserName.Text;
        string userpwd = txtLoginUserPwd.Text;
        string sql = "";
        if (this.DropDownList1.SelectedValue.Equals("教学人员"))
        {
            sql = "select * from users where no='" + username + "' and password='" + userpwd + "' and states='是' ";
            Session["types"] = "2";
        }
        else
        {
            sql = "select * from stu where no='" + username + "' and password='" + userpwd + "' and states='是' ";
            Session["types"] = "1";
        }

        DataTable dt = DB.getDataTable(sql);

        if (dt.Rows.Count > 0)
        {
            //写COOKIE
            HttpCookie cookie = new HttpCookie("memberinfo");
            cookie.Values["UserName"] = HttpContext.Current.Server.UrlEncode(txtLoginUserName.Text.Trim());
            cookie.Values["MemberId"] = dt.Rows[0]["id"].ToString();
            cookie.Values["MemberName"] = HttpContext.Current.Server.UrlEncode(dt.Rows[0]["realname"].ToString());
            Session["realname"] = dt.Rows[0]["realname"].ToString();

            HttpContext.Current.Response.AppendCookie(cookie);

后面还有 11 行代码,购买后查看完整代码

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

AI 解读 AI

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

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