温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:达达ASP.NET简单新闻发布源码
当前文件路径:DaDaNews/Admin/Default.aspx.cs

1using System; 2
using System.Collections; 3
using System.Configuration; 4
using System.Data; 5
using System.Data.SqlClient; 6
using System.Web; 7
using System.Web.Security; 8
using System.Web.UI; 9
using System.Web.UI.HtmlControls; 10
using System.Web.UI.WebControls; 11
using System.Web.UI.WebControls.WebParts; 12
13
14
public partial class _Default : System.Web.UI.Page 15
{ 16
protected void Button1_Click(object sender, EventArgs e) 17
{ 18
Db pn163 = new Db(); 19
//密码使用MD5加密 20
string Password = FormsAuthentication.HashPasswordForStoringInConfigFile(Pwd.Text.ToString(), "MD5"); 21
22
SqlConnection Conn = new SqlConnection(pn163.strConn); 23
24
SqlCommand Cmd = new SqlCommand("select * from Admin where UserAdmin='" + Uid.Text + "' and UserPwd = '" + Password + "' ", Conn); 25
26
Conn.Open(); 27
28
SqlDataReader Dr = Cmd.ExecuteReader(); 29
30
if (Uid.Text != "" && Pwd.Text !="") 31
{ 32
if (Dr.Read()) 33
{ 34
if (Chkcode.Text == Session["Code"].ToString()) 35
{ 36
Session["Admin"] = "Admin"; 37
Response.Write("<script>alert('登陆成功!');history.go(-1);</script>"); 38
Response.Redirect("./Main.aspx"); 39
} 40
else 41
{ 42
Response.Write("<script>alert('验证码错误!');history.go(-1);</script>"); 43
Chkcode.Focus(); 44
} 45
} 46
else 47
{ 48
Response.Write("<script>alert('用户名或密码错误!');history.go(-1);</script>"); 49
} 50
} 51
else 52
{ 53
Response.Write("<script>alert('请输入用户名和密码!');history.go(-1);</script>"); 54
} 55
} 56
} 57





}
}