代码拉取完成,页面将自动刷新
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Mysqlserver;
public partial class login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlServerDataBase obj = new SqlServerDataBase();
string email = TBemail.Text;
string password = TBpassword.Text;
byte[] result = Encoding.Default.GetBytes(password);
MD5 md5 = new MD5CryptoServiceProvider();
byte[] output = md5.ComputeHash(result);
string sql = "select *from [user] where email='" + email + "' and password='" + BitConverter.ToString(output).Replace("-", "") + "'";
DataSet ds = obj.Select(sql, null);
if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
{
Response.Write("<script>alert('该用户不存在')</script>");
}
else
{
string uid = ds.Tables[0].Rows[0][0].ToString();
string username = ds.Tables[0].Rows[0][1].ToString();
email = ds.Tables[0].Rows[0][2].ToString();
password = ds.Tables[0].Rows[0][3].ToString();
string role = ds.Tables[0].Rows[0][4].ToString();
Session["username"] = username;
Session["uid"] = uid;
Session["email"] = email;
Session["password"] = password;
Session["role"] = role;
if (role == "manager")
{
Response.Write("<script>alert('登录成功');window.location.href=\"manager/index.aspx\";</script>");
}
else if(role == "operator")
{
Response.Write("<script>alert('登录成功');window.location.href=\"operator/index.aspx\";</script>");
}
else if (role == "normal")
{
Response.Write("<script>alert('登录成功');window.location.href=\"normal/index.aspx\";</script>");
}
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。