📄 mabh.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Web.Mail;
namespace gllbysj
{
/// <summary>
/// mabh 的摘要说明。
/// </summary>
public class mabh : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Panel Panel2;
protected System.Web.UI.WebControls.HyperLink HyperLink1;
protected System.Web.UI.WebControls.LinkButton LinkButton4;
protected System.Web.UI.WebControls.LinkButton LinkButton2;
protected System.Web.UI.WebControls.LinkButton LinkButton3;
protected System.Web.UI.WebControls.TextBox TextBox3;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.LinkButton LinkButton1;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Panel Panel1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!this.IsPostBack)
{
this.rod();
}
}
public void rod()
{
string[]source={"0","1","2","3","4","5","6","7","8","9",
"A","B","C","D","E","F","G","H","I","J","K","L","M","N",
"O","P","Q","R","S","T","U","V","W","X","Y","Z"};
string code="";
Random rd=new Random();
for(int i=0;i<5;i++)
{
code+=source[rd.Next(0,source.Length)];
}
this.Label2.Text=code;
Session["code"]=code;
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click);
this.LinkButton3.Click += new System.EventHandler(this.LinkButton3_Click);
this.LinkButton2.Click += new System.EventHandler(this.LinkButton2_Click);
this.LinkButton4.Click += new System.EventHandler(this.LinkButton4_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void LinkButton1_Click(object sender, System.EventArgs e)
{
string str="select * from user1 where name='"+this.TextBox1.Text+"'";
SqlConnection cn=db.createcon();
cn.Open();
SqlCommand cmm=new SqlCommand(str,cn);
SqlDataReader sdr=cmm.ExecuteReader();
if(sdr.Read())
{
//Response.Write(sdr["quest"].ToString());
if(sdr["quest"].ToString()!="")
{
//Response.Write("不为空");
this.Label1.Text=sdr["quest"].ToString();
this.Panel1.Visible=false;
this.Panel2.Visible=true;
}
else
{
Response.Write("<script langeage=javascript>alert('您还没有申请保护!')</script>");
this.HyperLink1.Visible=true;
//Response.Write("空");
}
}
else
{
Response.Write("<script language=javascript>alert('用户不存在')</script>");
}
cn.Close();
}
private void LinkButton3_Click(object sender, System.EventArgs e)
{
this.rod();
}
private void LinkButton2_Click(object sender, System.EventArgs e)
{
if(this.TextBox3.Text==Session["code"].ToString())
{
string str="select * from user1 where name='"+this.TextBox1.Text+"'";
SqlConnection cn=db.createcon();
cn.Open();
SqlCommand cmm=new SqlCommand(str,cn);
SqlDataReader sdr=cmm.ExecuteReader();
sdr.Read();
if(sdr["answer"].ToString()==this.TextBox2.Text)
{
//this.Label3.Text="当前密码为:"+sdr["password"].ToString();
// me.From="adb@163.com";
//string s="您的密码为:"+sdr["password"].ToString();
// string s="密码已发送到您的邮件地址,请查收!";
/* MailMessage msg=new MailMessage();
msg.To=sdr["mail"].ToString();
//msg.To="ybbuuuuss521@163.com";
msg.From="ybbuuuuss521@163.com";
msg.Subject="密码找回";
//msg.Body="您的当前密码为:['"+sdr["password"].ToString()+"']建议您尽快此网站修改您的密码:http://localhost/gllbysj/baohu.aspx";
msg.Body="";
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate","1");
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","ybbuuuuss521@163.com");
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","tkggipgmy");
//try
// {
SmtpMail.SmtpServer="smtp.163.com";
SmtpMail.Send( msg );*/
MailMessage mail = new MailMessage();
//mail.To = "ybbuuuuss521@163.com";
mail.To=sdr["mail"].ToString().Trim();
mail.From = "ybbuuuuss521@163.com";
mail.Subject = "密码找回";
mail.Body = "您的当前密码为:["+sdr["password"].ToString()+"]建议您尽快此网站修改您的密码:http://localhost/gllbysj/baohu.aspx";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "ybbuuuuss521@163.com");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "tkggipgmy");
SmtpMail.SmtpServer = "smtp.163.com";
SmtpMail.Send( mail );
Response.Write("<script language=javascript>alert('密码已发送到您的邮件地址,请查收!');location='mabh.aspx'</script>");
//}
//catch
//{
// Response.Write("<script language=javascript>alert('数据库错误!')</script>");
// }
// me.To==sdr["mail"].ToString();
//me.Body=sdr["password"].ToString();
//Response.Redirect("mabh.aspx");
}
else
{
Response.Write("<script language=javascript>alert('您的回答不正确!')</script>");
}
cn.Close();
}
else
{
Response.Write("<script language=javascript>alert('验证码不正确!')</script>");
//Response.Write(Session["code"].ToString());
}
}
private void LinkButton4_Click(object sender, System.EventArgs e)
{
Response.Redirect("mabh.aspx");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -