示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.IsPostBack)
        {
            string UName2   = Request.Form["username"];
            string Pass2    = Request.Form["password"];
            string FName2   = Request.Form["firstname"];
            string LName2   = Request.Form["lastname"];
            string sex2     = Request.Form["sex"];
            string Area2    = Request.Form["area"];
            string City2    = Request.Form["add_city"];
            string Street2  = Request.Form["add_street"];
            string SNum2    = Request.Form["add_num"];
            string Mail2    = Request.Form["mail"];
            string HomeNum2 = Request.Form["homenum"];
            string CellNum2 = Request.Form["cellnum"];

            string sql1 = string.Format("UPDATE tUsers SET username ='******', pass ='******', firstname ='{2}', lastname ='{3}', sex ='{4}', area ='{5}', add_city ='{6}', add_street ='{7}', add_num ='{8}', mail ='{9}', homenum ='{10}',cellnum = '{11}' WHERE (username ='******')", UName2, Pass2, FName2, LName2, sex2, Area2, City2, Street2, SNum2, Mail2, HomeNum2, CellNum2, UName2);
            MyDbase.ChangeTable(sql1, "tUsers.accdb");
            Response.Redirect("ShowUsersTable.aspx");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            Response.Write("<body dir='rtl'>");
            string user_name = Request.Form["text1"];
            string lest_name = Request.Form["text2"];
            string pass_word = Request.Form["password"];
            string age       = Request.Form["text3"];
            string gender    = Request.Form["radio"];
            string hoby      = Request.Form["DDL"];

            string sql1 = "SELECT * FROM AcsessTeble WHERE FN=" + "'" + user_name + "'";
            System.Data.DataTable dt = MyDbase.SelectFromTable(sql1, "AccessFile.accdb");

            if (dt.Rows.Count == 0)
            {
                //string sql = "INSERT INTO AcsessTeble(FN,LN)" +"values(" + "'" + user_name + "','" + lest_name + "')";
                //MyDbase.ChangeTable(sql, "AccessFile.accdb");

                //string sql = "INSERT INTO AcsessTeble(FN)" +
                //   "values(" + "'" + user_name + "')";

                string sql = "INSERT INTO AcsessTeble(FN,LN,PW,Age_fild,gender,hoby)" +
                             "values(" + "'" + user_name + "','" + lest_name + "','" + pass_word + "','" + age + "','" + gender + "','" + hoby + "')";
                MyDbase.ChangeTable(sql, "AccessFile.accdb");

                Session["login"] = user_name;  // יצירת סשן עם שם משתמש
                Response.Redirect("Success.aspx");
            }
            else
            {
                Response.Redirect("Erorr.aspx");
            }
        }
    }