Esempio n. 1
0
        private void skinButton_Register_Click(object sender, EventArgs e)
        {
            string username = Register_username.Text;
            string pass     = Register_pswd.Text;
            string passinfo = Register_pswdinfo.Text;
            string mail     = Register_email.Text;
            Regex  r        = new Regex("^\\s*([A-Za-z0-9_-]+(\\.\\w+)*@(\\w+\\.)+\\w{2,5})\\s*$");

            if (!r.IsMatch(mail))
            {
                MessageBox.Show("邮箱格式有误!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (username != "" && pass != "" && passinfo != "" && mail != "")
            {
                if (pass.Equals(passinfo))
                {
                    //创建Email对象
                    Email email = new Email();
                    email.mailFrom    = "发送地址";
                    email.mailPwd     = "*******";
                    email.mailSubject = "CloudKeys---安心的密码管家";
                    email.mailBody    = "请妥善保管您的账号与密码:" + username + "&" + pass;
                    email.isbodyHtml  = true;
                    email.host        = "smtp.163.com";//根据自己情况更改
                    email.mailTo      = mail;

                    string url = XMLDealTool.getUrlPath() + "cloudkey/signin.php";
                    username = Encrypt.GetMd5Hash(username);
                    pass     = Encrypt.StringToBase64string(pass);
                    string data   = "username="******"&password="******"&Email=" + mail;
                    string result = HttpGet.HttpGet_test(url, data);

                    if (result.IndexOf("Error") == -1)
                    {
                        if (email.Send())
                        {
                            MessageBox.Show("注册成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            System.Diagnostics.Process.Start("explorer.exe", XMLDealTool.getUrlPath() + "cloudkey/success.php");
                        }
                        this.Hide();
                        login.Show();
                        this.Dispose();
                    }
                    else
                    {
                        MessageBox.Show("注册失败!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("两次输入的密码不一致!", "ERROR",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("请填写完整信息!", "WARN",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
            }
        }