这个是我完整的代码,管理的那里我不知道设计,我在数据库设计的密码为123456,不过我知道加密后就不是123456,;可我不知道怎么设计加密密码,
public partial class login_usercontrol : System.Web.UI.UserControl
{
String SqlStr;
DB db = new DB();
DataSet Ds = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn_Login_Click(object sender, EventArgs e)
{
String Md5_User_Pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(this.txt_User_Pwd.Text.ToString(), "MD5");
SqlStr = "select * from 会员表 where 会员名='" + this.txt_User_Name.Text + "' and 密码='" + Md5_User_Pwd + "'";
Ds = db.GetDataTableBySql(SqlStr);
try
{
if (Ds.Tables[0].Rows.Count == 0)
{
this.Labinfo.Text = "用户名或密码错误,请重试!";
this.txt_User_Name.Focus();
}
else
{
this.Labinfo.Text = "用户 " + this.txt_User_Name.Text + " 恭喜您登录成功!";
Session["UserName"] = this.txt_User_Name.Text;
}
}
catch (Exception)
{
this.Labinfo.Text = "没有得到任何数据,请重试!";
}
}
protected void btn_Register_Click(object sender, EventArgs e)
{
Response.Redirect("zhuce.aspx");
}
protected void Button1_Click(object sender, EventArgs e)
{
String Md5_User_Pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(this.txt_User_Pwd.Text.ToString(), "MD5");
SqlStr = "select * from 管理员表 where 用户名='" + this.txt_User_Name.Text + "' and 密码='" + Md5_User_Pwd + "'";
Ds = db.GetDataTableBySql(SqlStr);
try
{
if (Ds.Tables[0].Rows.Count == 0)
{
this.Labinfo.Text = "用户名或密码错误,请重试!";
this.txt_User_Name.Focus();
}
else
{
this.Labinfo.Text = "管理员 " + this.txt_User_Name.Text + " 恭喜您登录成功!";
Session["Admin_UserName"] = this.txt_User_Name.Text;
}
}
catch (Exception)
{
this.Labinfo.Text = "没有得到任何数据,请重试!";
}
}
}