Example #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Request.IsSecureConnection)
        {
            // redirect visitor to SSL connection
            Response.Redirect(Request.Url.AbsoluteUri.Replace("http://", "https://"));
        }

        //get variables from URL
        string linkClient = Request.QueryString["user"];
        string linkCode   = Request.QueryString["code"];

        DateTime dateSent = new DateTime();
        string   code = "", email = "";

        ConnectionClass.DateCodeActivateAccount(linkClient, ref dateSent, ref code, ref email);

        if (code == linkCode && DateTime.Now <= dateSent.AddDays(3) && linkCode != "null")
        {
            ConnectionClass.ActivateAccount(email);
            lblResult.Text          = "Your account has been successfully activated!";
            lBtnCodeRequest.Visible = false;
        }
        else
        {
            if (DateTime.Now > dateSent.AddDays(3))
            {
                lblResult.Text = "Your activation link has expired!";
            }
            else
            {
                lblResult.Text = "Please register your account! <br /><br />" +
                                 "An email was sent to you when you registered with this addres.<br />" +
                                 "If you cannot find it, please check your spam folder too!<br />" +
                                 "If you still cannot find it:";
            }
            lBtnCodeRequest.Visible = true;
        }
    }