예제 #1
0
    protected void btnSendEmail_Click(object sender, EventArgs e)
    {
        SpecialOperations operate   = new SpecialOperations();
        string            checkCode = operate.generateRandomNum(6);

        Session["checkCode"] = checkCode;
        string body = "你的验证码是" + checkCode; //生成六位验证码发送至邮箱
        string toEmail;

        if (txtEmail.Text != null && txtEmail.Text != "" && !operate.non_string_existed(txtEmail.Text, "@") && !operate.non_string_existed(txtEmail.Text, ".com"))
        {
            toEmail = txtEmail.Text;
            if (operate.EmailSend(body, toEmail))
            {
                Response.Write("<script> alert('验证码已发送至邮箱,请及时查收!');</script> ");
            }
            else
            {
                Response.Write("<script> alert('验证码发送失败!');</script> ");
            }
        }
        else
        {
            Response.Write("<script> alert('邮箱格式不正确');</script> ");
            txtEmail.Text = null;
        }
    }
예제 #2
0
    protected void btnSendCode_Click(object sender, EventArgs e)
    {
        string            number = txtNumber.Text;
        string            getEmail;
        SpecialOperations operate    = new SpecialOperations();
        SQLOperation      sqlOperate = new SQLOperation();
        DataTable         dt         = new DataTable();

        if (number == null || number == "")
        {
            Response.Write("<script> alert('请输入账号!');</script> ");
            txtPwdSet.Text  = null;
            txtPwdSure.Text = null;
        }
        else
        {
            dt = sqlOperate.select(" email ", " users ", " number='" + number + "'");
            if (dt.Rows.Count == 0)
            {
                Response.Write("<script> alert('账号不存在');</script> "); txtNumber.Text = null;
            }
            else
            {
                getEmail = dt.Rows[0][0].ToString();

                Session["checkCode"] = operate.generateRandomNum(6);
                string body = "你的验证码是" + Session["checkCode"].ToString(); //生成六位验证码发送至邮箱

                if (operate.EmailSend(body, getEmail))
                {
                    Response.Write("<script> alert('验证码已发送至邮箱,请及时查收!');</script> ");
                }
                else
                {
                    Response.Write("<script> alert('验证码发送失败!');</script> ");
                }
            }
        }
    }