Exemple #1
0
        protected void btn_submit_Click(object sender, EventArgs e)
        {
            string Catpcha = Session["CAPTCHA"].ToString();

            string[] sub = txtregDOB.Text.Split('/');
            string   DOB = sub[2] + "/" + sub[1] + "/" + sub[0];
            DateTime d   = DateTime.Parse(DOB);

            if (txtregCaptcha.Text != "")
            {
                if (txtregCaptcha.Text.Equals(Catpcha))
                {
                    string   query   = "Select count(*) from Users where Email = '" + txtregEmail.Text + "' ";
                    FUF_User execute = new FUF_User();
                    int      rv      = Convert.ToInt32(execute.ExecuteQuery_ExecuteScalar(query));
                    if (rv > 0)
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "Script", "alert('Email is already registered; Please try with other email');window.location='index.aspx'", true);
                    }
                    else
                    {
                        query = "Select count(*) from Users";
                        int id = Convert.ToInt32(execute.ExecuteQuery_ExecuteScalar(query));
                        id    = id + 1;
                        query = "Insert into Users (UserID,UserName, Email, City,Password,DOB,MobileNo) values ('" + id + "', '" + txtregName.Text + "', '" + txtregEmail.Text + "','" + txtregCity.Text + "' ,'" + txtregCpass.Text + "', '" + d.Date.ToString("yyyy/MM/dd") + "','" + txtregMobile.Text + "') ";
                        try
                        {
                            execute.ExecuteQuery_Update(query);
                            ScriptManager.RegisterStartupScript(this, GetType(), "Script", "alert('You have registered succesfully');window.location='index.aspx'", true);
                        }
                        catch (Exception ex)
                        {
                            throw (ex);
                        }
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "Script", "alert('Catpcha must be match')", true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "Script", "alert('Please Enter Capcha')", true);
            }
        }