String md5pwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(pwd, "md5");
try
{
con.Open();
OleDbCommand com = new OleDbCommand("select * from Admin_Users where Admin_User_Name='" + user + "' and Admin_User_Pwd='" + md5pwd + "'", con);
OleDbDataReader dr = com.ExecuteReader();
if (dr.Read())
{
HttpCookie usersCookie = new HttpCookie("user", dr["Admin_User_Name"].ToString());
Response.Cookies.Add(usersCookie);
Response.Redirect("Default.aspx");
}
else
{
Response.Write("<script>alert('用户名或密码错误!');</script>");
}
}
catch (Exception ex)
{
Response.Write("<script>alert('" + ex.Message + "');</script>");
}
finally
{
con.Close();
}
try
{
con.Open();
OleDbCommand com = new OleDbCommand("select * from Admin_Users where Admin_User_Name='" + user + "' and Admin_User_Pwd='" + md5pwd + "'", con);
OleDbDataReader dr = com.ExecuteReader();
if (dr.Read())
{
HttpCookie usersCookie = new HttpCookie("user", dr["Admin_User_Name"].ToString());
Response.Cookies.Add(usersCookie);
Response.Redirect("Default.aspx");
}
else
{
Response.Write("<script>alert('用户名或密码错误!');</script>");
}
}
catch (Exception ex)
{
Response.Write("<script>alert('" + ex.Message + "');</script>");
}
finally
{
con.Close();
}
解决方案 »
- 谁为我解释一下 “^” 运算符
- 前面都加了public了,可是还提示"可访问性不一致: 字段类型..”
- ICSharpCode zgip格式,压缩文件夹
- C# 读取Word目录树
- 请思归老大给看一下这个正则怎么写?
- 在其中一台电脑中用麦克风说话,其它电脑能实时的收听到声音(大概是40个点,局网),求解决方案。各位能说个思路吗
- C#的两个问题,新人先谢谢大家
- 求高手帮我做个小系统
- 关于XmlNode对XML操作的问题
- 来来来,给你们出个难题,很有意思!关于ObjectListView控件的,如果没听过,可以当成是listView控件就OK了,原理应该一样!
- 在一个窗体上,用GDI+显示了一图片,还有一个工具栏,当图片大于窗体大小时,拖动滚动条后,工具栏也跟着一起滚动?如何让工具栏不动?
- 请教专业人才与高手(感谢之余绝不吝啬给分)!!
String md5pwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(pwd, "md5");
try
{
//操作数据库
con.Open();
OleDbCommand com = new OleDbCommand("select * from Admin_Users where Admin_User_Name='" + user + "' and Admin_User_Pwd='" + md5pwd + "'", con);
OleDbDataReader dr = com.ExecuteReader();
if (dr.Read())
{
HttpCookie usersCookie = new HttpCookie("user", dr["Admin_User_Name"].ToString());
Response.Cookies.Add(usersCookie);
Response.Redirect("Default.aspx");
}
else
{
Response.Write(" <script>alert('用户名或密码错误!'); </script>");
}
}
catch (Exception ex)
{
Response.Write(" <script>alert('" + ex.Message + "'); </script>");
}
finally
{
con.Close();
}