2 Star 7 Fork 1

zorro_ku_o / hotel

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
login.aspx.cs 2.20 KB
一键复制 编辑 原始数据 按行查看 历史
zorro_ku_o 提交于 2015-06-02 15:01 . 数据库操作
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>");
}
}
}
}
ASP
1
https://gitee.com/huangang/hotel.git
git@gitee.com:huangang/hotel.git
huangang
hotel
hotel
master

搜索帮助