• 图书自动登录找回密码


    图书3


    登录
    1
    <%@ Page Title="" Language="C#" MasterPageFile="~/Master/MainMaster.Master" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="BookShop.Web.Member.Login" %> 2 <asp:Content ID="Content1" ContentPlaceHolderID="Header" runat="server"> 3 </asp:Content> 4 <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> 5 6 <table width="60%" height="22" border="0" align="center" cellpadding="0" cellspacing="0" runat="server" id="tblfirst"> 7 <tr> 8 <td width="10"><img src="/Images/az-tan-top-left-round-corner.gif" width="10" height="28" /></td> 9 <td bgcolor="#DDDDCC"><span style="font-family: '黑体';font-size: 16px;color: #660000;">登录网上书店</span></td> 10 <td width="10"><img src="/Images/az-tan-top-right-round-corner.gif" width="10" height="28" /></td> 11 </tr> 12 </table> 13 <table width="60%" height="22" border="0" align="center" cellpadding="0" cellspacing="0" runat="server" id="tblsecend"> 14 <tr> 15 <td bgcolor="#DDDDCC" style=" 2px">&nbsp;</td> 16 <td><div align="center"> 17 <table height="61" cellpadding="0" cellspacing="0"> 18 <tr> 19 <td height="33" colspan="6"> 20 <p style="font-size:14px;font-weight: bold;color: #FF9900; text-align: center;">已注册用户请从这里登录</p></td> 21 </tr> 22 <tr> 23 <td width="24%" height="26" rowspan="2" align="right" valign="top"><strong>用户名:</strong></td> 24 <td valign="top" width="37%"> 25 &nbsp;<input type="text" name="txtLoginId" /></td> 26 </tr> 27 </table> 28 <table height="61" cellpadding="0" cellspacing="0"> 29 <tr> 30 <td height="1" colspan="2"></td> 31 </tr> 32 <tr> 33 <td width="24%" height="26" rowspan="3" align="right" valign="top"><strong>密 码:</strong></td> 34 <td valign="top" width="37%"> 35 &nbsp;<input type="password" name="txtLoginPwd" /></td> 36 </tr> 37 38 <tr> 39 <td valign="top" width="37%"> 40 <input type="checkbox" name="cbAutoLogin" value="1"/>记住我 41 </td> 42 </tr> 43 44 </table> 45 <div> 46 <input type="hidden" name="hiddenReturnUrl" value="<%=ReturnUrl %>" /> 47 <input type="image" src="/Images/az-login-gold-3d.gif" /> 48 49 <%if(string.IsNullOrEmpty(ReturnUrl)){%> 50 <a href="Register.aspx">注册</a> 51 <%}else{%> 52 <a href="Register.aspx?returnUrl=<%=ReturnUrl%>">注册</a> 53 <%} %> 54 <a href="FindPwd.aspx">忘记密码</a> 55 56 </div> 57 </div> 58 <div > 59 <div align="center"> 60 &nbsp;</div> 61 </div> 62 </td> 63 <td width="2" bgcolor="#DDDDCC">&nbsp;</td> 64 </tr> 65 </table> 66 <table width="60%" height="3" border="0" align="center" cellpadding="0" cellspacing="0" runat="server" id="tblthird"> 67 <tr align="center"> 68 <td height="3" bgcolor="#DDDDCC"> 69 &nbsp; 70 </td> 71 </tr> 72 </table> 73 74 75 76 </asp:Content>

    找回密码

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Net.Mail;
     5 using System.Web;
     6 using System.Web.UI;
     7 using System.Web.UI.WebControls;
     8 
     9 namespace BookShop.Web.Member
    10 {
    11     public partial class Login : System.Web.UI.Page
    12     {
    13         public string Msg { get; set; }
    14         public string ReturnUrl = string.Empty;
    15         BLL.UserManager UserManager = new BLL.UserManager();
    16         protected void Page_Load(object sender, EventArgs e)
    17         {
    18             if (IsPostBack)
    19             {
    20                 UserLogin();
    21             }
    22             else
    23             {
    24                 ReturnUrl = Request["returnUrl"];//如果能够接收到传递过来的参数(存储的是用户接下来要访问的URL地址),把数据存储到隐藏域中。
    25                 //校验Cookie中是否有值
    26                 CheckCookieInfo();
    27 
    28               
    29             }
    30         }
    31         /// <summary>
    32         /// 校验Cookie的值
    33         /// </summary>
    34         private void CheckCookieInfo()
    35         {
    36             if (Request.Cookies["cp1"] != null && Request.Cookies["cp2"] != null)
    37             {
    38                 string userName = Request.Cookies["cp1"].Value;
    39                 string userPwd = Request.Cookies["cp2"].Value;
    40                 Model.User userInfo=UserManager.GetModel(userName);
    41                 if (userInfo != null)
    42                 {
    43                     if (userPwd == Common.WebCommon.GetMd5String(Common.WebCommon.GetMd5String(userInfo.LoginPwd)))
    44                     {
    45                         Session["userInfo"] = userInfo;
    46                         if (!string.IsNullOrEmpty(Request["returnUrl"]))
    47                         {
    48                             Response.Redirect(Request["returnUrl"]);
    49                         }
    50                         else
    51                         {
    52                             Response.Redirect("/Default.aspx");
    53                         }
    54                     }
    55                 }
    56                 Response.Cookies["cp1"].Expires = DateTime.Now.AddDays(-1);
    57                 Response.Cookies["cp2"].Expires = DateTime.Now.AddDays(-1);
    58             }
    59         }
    60 
    61         private void UserLogin()
    62         {
    63             string userName = Request["txtLoginId"];
    64             string userPwd =Request["txtLoginPwd"];
    65             string msg = string.Empty;
    66             Model.User userInfo = null;
    67          
    68             bool b = UserManager.CheckUserInfo(userName, userPwd, out msg, out userInfo);
    69             if (b)
    70             {
    71                 Session["userInfo"] = userInfo;
    72                 //判断用户是否选择了”自动登录“
    73                 if (!string.IsNullOrEmpty(Request["cbAutoLogin"]))
    74                 {
    75                     HttpCookie cookie1 = new HttpCookie("cp1",userName);
    76                     HttpCookie cookie2 = new HttpCookie("cp2", Common.WebCommon.GetMd5String(Common.WebCommon.GetMd5String(userPwd)));
    77                     cookie1.Expires = DateTime.Now.AddDays(7);
    78                     cookie2.Expires = DateTime.Now.AddDays(7);
    79                     Response.Cookies.Add(cookie1);
    80                     Response.Cookies.Add(cookie2);
    81                 }
    82 
    83                 //单击提交按钮,会将隐藏域的值提交过来。
    84                 if (string.IsNullOrEmpty(Request["hiddenReturnUrl"]))
    85                 {
    86                     Response.Redirect("/Default.aspx");
    87                 }
    88                 else
    89                 {
    90                     Response.Redirect(Request["hiddenReturnUrl"]);
    91                 }
    92             }
    93             else
    94             {
    95                 Msg = msg;
    96             }
    97         }
    98     }
    99 }

    找回密码

     1  public class FindPwd : IHttpHandler
     2     {
     3 
     4         public void ProcessRequest(HttpContext context)
     5         {
     6             context.Response.ContentType = "text/plain";
     7             string name = context.Request["name"];
     8             string mail=context.Request["mail"];
     9             BLL.UserManager UserInfoManager = new BLL.UserManager();
    10             Model.User userInfo = UserInfoManager.GetModel(name);
    11             if (userInfo != null)
    12             {
    13                 if (userInfo.Mail == mail)
    14                 {
    15                     UserInfoManager.FindUserPwd(userInfo);//找回用户的密码在bll 
    16                 }
    17                 else
    18                 {
    19                     context.Response.Write("邮箱错误!!");
    20                 }
    21             }
    22             else
    23             {
    24                 context.Response.Write("查无此人!!");
    25             }
    26         }
    27 
    28         public bool IsReusable
    29         {
    30             get
    31             {
    32                 return false;
    33             }
    34         }
    35     }
  • 相关阅读:
    设置打印 页面 方向与大小
    设置对齐
    设置字体
    SVN版本管理与大型代码上线方案(一)
    项目案例之Pipeline流水线及流水线发布PHP项目(二)
    Jenkins企业应用进阶详解(一)
    iptables 防火墙(下)
    iptables 防火墙(上)
    zabbix生产环境案例(三)
    深入理解zabbix(二)
  • 原文地址:https://www.cnblogs.com/liuweiqiang11188/p/6686447.html
Copyright © 2020-2023  润新知