asp.net实现邮箱取回密码
作者 佚名技术
来源 NET编程
浏览
发布时间 2012-04-12
="server" Text=" 找回密码 " /></td> </tr> </table> </td> </tr> </table> </div> </form> </body> </html> using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class ClientServer_Default2 : System.Web.UI.Page { string lspass = ""; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.Button1.Attributes.Add("onclick", "javascript:return checkAll();"); } } protected void Button1_Click(object sender, EventArgs e) { HttpCookie myCookie_validcode = Request.Cookies["FWCX_CheckCode"]; if (myCookie_validcode.Value.ToString() != txt_validcode.Text) { Response.Write("<script>"); Response.Write("alert(''验证码错误'')"); Response.Write("</script>"); return; } //首先判断该登录名称和email是否存在 string sql = "select * from t_users where u_username=''" + username.Text.Trim() + "'' and u_email=''" + email.Text.Trim() + "'' and u_class=''0'' and u_valid=''1''"; DataTable dt = new DataTable(); //dt = new SQLTool().dataTable(sql); if (dt.Rows.Count < 1) { Response.Write("<script>alert(''登录名称或Email地址错误!,请重新填写后再试。'');</script>"); } else { //首先给现在的数据库t_users附上一个临时密码 //Response.Write(CreateRandomCode(8)); lspass = CreateRandomCode(8); sql = "update t_users set u_getpwd=''" + lspass + "'' where u_username=''" + username.Text.Trim() + "'' and u_email=''" + email.Text.Trim() + "'' and u_class=''0'' and u_valid=''1''"; //if (new SQLTool().ExecuteSql(sql) >= 0) //{ sendEmail(email.Text.Trim(), username.Text.Trim()); Response.Write("<script>alert(''临时密码已经发送到您的注册Email中,请在下一页面中修改密码。'');window.location.href=''getpwdconfirm.aspx'';</script>"); //} } } public void sendEmail(string email, string name) { try { jmail.Message jmessage = new jmail.Message(); jmessage.Charset = "GB2312"; jmessage.From = "86085005@163.com"; // 发信地址 jmessage.MailServerUserName = "86085005"; //smtp认证用户名(注:如为网易用户,不加要@163.com,只要前面部分即可) jmessage.MailServerPassWord = "kingseer"; // smtp论证用户名密码 jmessage.FromName = "108人力银行"; // 发信人 jmessage.ReplyTo = "86085005@163.com"; // 回复地址 jmessage.C;//邮件内容为html jmessage.Subject = "108人力银行临时密码"; string strbody = ""; strbody += new functions().getInfoXX("t_pagetexts", "p_name", "找回密码邮件反馈-个人", "p_value").Replace("contentquot;, name).Replace("@%", lspass); jmessage.HTMLBody = strb |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
上一篇: ascx访问aspx页面的两种方法下一篇: C#实现保留2位小数
关于asp.net实现邮箱取回密码的所有评论