zoukankan      html  css  js  c++  java
  • 找回密码

    <asp:LinkButton ID="butGetPSW" runat="server" Font-Underline="True"
                                                TabIndex="5" CausesValidation="False" OnClick="butGetPSW_Click">找回密码</asp:LinkButton>

    后台:

     protected void butGetPSW_Click(object sender, EventArgs e)
        {
            if (txtLoginName.Text == null && txtLoginName.Text == "")
            {
                lblLogin.Text = "请输入登录名!";
                return;
            }
            string value = ZZ.Conn.Connection.getSqlValue("select count(1) from UserInfo where LoginName='" + txtLoginName.Text + "'");
            if (value.Equals("0"))
            {
                lblLogin.Text = "当前用户不存在!";
                return;
            }
            Session["LoginName"] = txtLoginName.Text;
            if (butGetPSW.Text == "找回密码")
            {
                Random r = new Random();
                Session["Number"] = r.Next(1000, 9999);
                string mall = ZZ.Conn.Connection.getSqlValue("select EmailAddress from UserInfo where LoginName='" + txtLoginName.Text + "'");
                if (mall != null && mall != "")
                {
                    try
                    {
                        MailMessage mailObj = new MailMessage();
                        mailObj.From = new MailAddress(Session["EmailAddress"].ToString()); //发送人邮箱地址
                        mailObj.To.Add(mall);   //收件人邮箱地址
                        mailObj.Subject = "验证信息";    //主题
                        mailObj.Body = "本次验证码:" + Session["number"];    //正文    
                        SmtpClient smtp = new SmtpClient();
                        smtp.Host = "smtp.qq.com";         //smtp服务器名称
                        smtp.UseDefaultCredentials = true;
                        smtp.Credentials = new NetworkCredential(Session["EmailAddress"].ToString(), Session["EmailPassWord"].ToString());  //发送人的登录名和密码
                        smtp.Send(mailObj);
                    }
                    catch (Exception ex)
                    {
                        lblLogin.Text = "系统繁忙!请稍后再试";
                        return;
                    }
                }
            }
            else
            {
                Session["Number"] = "0000";
            }
            Response.Redirect("~/SysTemMaintain/UserPower/FindPassWord.aspx");
    
        }
  • 相关阅读:
    黑客是如何知道我们常用的密码的
    一个核物理学霸为何两次收到BlackHat的邀请
    透过大数据剖析漫画何去何从
    SJF(最短作业优先)
    RR(轮转调度算法)
    hrrf(最高响应比)
    fcfs
    Process 2(完成版)
    进程2
    进程1
  • 原文地址:https://www.cnblogs.com/Echo529/p/4556933.html
Copyright © 2011-2022 走看看