string Utype; Utype = dt.Rows[0][5].ToString().Trim(); if(Utype=="U") { Session["USERNAME"] = UserName.Text; Response.Redirect("~/UserHome.aspx"); } if (Utype == "A") { Session["USERNAME"] = UserName.Text; Response.Redirect("~/AdminHome.aspx"); }
protected void Button1_Click(object sender, EventArgs e) { String CS = ConfigurationManager.ConnectionStrings["MyDatabaseConnectionString1"].ConnectionString; using (SqlConnection con = new SqlConnection(CS)) { SqlCommand cmd = new SqlCommand("select * from Users where Username='"+UserName.Text+"' and Password='"+Password.Text+"'",con); con.Open(); SqlDataAdapter sda = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); sda.Fill(dt); if (dt.Rows.Count!=0) { if (CheckBox1.Checked) { Response.Cookies["UNAME"].Value = UserName.Text; Response.Cookies["PWD"].Value = Password.Text; Response.Cookies["UNAME"].Expires = DateTime.Now.AddDays(15); Response.Cookies["PWD"].Expires = DateTime.Now.AddDays(15); } else { Response.Cookies["UNAME"].Expires = DateTime.Now.AddDays(-1); Response.Cookies["PWD"].Expires = DateTime.Now.AddDays(-1); } string Utype; Utype = dt.Rows[0][5].ToString().Trim(); if(Utype=="U") { Session["USERNAME"] = UserName.Text; Response.Redirect("~/UserHome.aspx"); } if (Utype == "A") { Session["USERNAME"] = UserName.Text; Response.Redirect("~/AdminHome.aspx"); } } else { lblError.Text = "Invalid Username or Password !"; } } } }
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง