using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Configuration; public partial class Login : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RegConnectionString"].ConnectionString); con.Open(); string cmdstr = "Select count(*) from Registration where UserName='" + TextBox1.Text + "'"; SqlCommand checkuser = new SqlCommand(cmdstr, con); int temp = Convert.ToInt32(checkuser.ExecuteScalar().ToString()); if (temp == 1) { string cmdstr2 = "Select UserStatus from Registration where UserStatus='" + TextBox1.Text + "'"; SqlCommand Userst = new SqlCommand(cmdstr2, con); string UserStatus = Userst.ExecuteScalar().ToString(); con.Close(); if (UserStatus == "Admin") { Session["New"] = "Admin"; Response.Redirect("Admin.aspx"); } if (UserStatus == "บ้านหลังที่ 1") { Session["New"] = TextBox1.Text; Response.Redirect("Secure.aspx"); } if (UserStatus == "บ้านหลังที่ 2") { Session["New"] = TextBox1.Text; Response.Redirect("Secure2.aspx"); } else { Label1.Visible = true; Label1.Text = "Invalid Password...!!"; } } else { Label1.Visible = true; Label1.Text = "Invalid UserName...!!"; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Configuration; public partial class Login : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RegConnectionString"].ConnectionString); con.Open(); string cmdstr = "Select count(*) from Register where UserName='" + TextBox1.Text + "'"; SqlCommand checkuser = new SqlCommand(cmdstr, con); int temp = Convert.ToInt32(checkuser.ExecuteScalar().ToString()); if (temp == 1) { string cmdstr2 = "Select UserStatus from Register where UserStatus='" + TextBox1.Text + "'"; SqlCommand Userst = new SqlCommand(cmdstr2, con); string UserStatus = Userst.ExecuteScalar().ToString(); con.Close(); if (UserStatus == "Admin") { Session["New"] = "Admin"; Response.Redirect("Admin.aspx"); } if (UserStatus == "บ้านหลังที่ 1") { Session["New"] = "บ้านหลังที่ 1"; Response.Redirect("Secure.aspx"); } if (UserStatus == "บ้านหลังที่ 2") { Session["New"] = "บ้านหลังที่ 2"; Response.Redirect("Secure2.aspx"); } else { Label1.Visible = true; Label1.Text = "Invalid Password...!!"; } } else { Label1.Visible = true; Label1.Text = "Invalid UserName...!!"; } } }
strSQL = "SELECT * FROM customer WHERE Username = '"+this.txtUser.Text+"' AND Password = '"+this.txtPassword.Text+"' "; objConn.ConnectionString = strConnString; objCmd.Connection = objConn; objCmd.CommandText = strSQL; objCmd.CommandType = CommandType.Text; dtAdapter.SelectCommand = objCmd; dtAdapter.Fill(ds); dt = ds.Tables[0]; if(dt.Rows.Count == 0) { // Failed } else { if(dt.Rows[0]["Status"] == "Admin") { // } else { // } }
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง