using System; using System.Data; 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) { if (IsPostBack) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["PassConnectionString"].ConnectionString); con.Open(); string cmdStr = "select count(*) from TableCEO where EmailAddress='" + TextBox1.Text + "'"; SqlCommand userExist = new SqlCommand(cmdStr, con); int temp = Convert.ToInt32(userExist.ExecuteScalar().ToString()); con.Close(); if (temp == 1) { Response.Write("User Name Already Exist!!!"); } } } protected void Button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["PassConnectionString"].ConnectionString); con.Open(); string insCmd = "Insert into TableSecurity (EmailAddress, Password, Level) values (@EmailAddress, @Password, @Level)"; SqlCommand insertUser = new SqlCommand(insCmd, con); insertUser.Parameters.AddWithValue("@EmailAddress", TextBox1.Text); insertUser.Parameters.AddWithValue("@Password", TextBox2.Text); insertUser.Parameters.AddWithValue("@Level", TextBox1.Text); string cmdStr = "select count(*) from TableCEO where EmailAddress='" + TextBox1.Text + "'"; SqlCommand Checkuser = new SqlCommand(cmdStr, con); int temp = Convert.ToInt32(Checkuser.ExecuteScalar().ToString()); if (temp == 1) { string cmdStr2 = "Select Password from TableSecurity where Password='" + TextBox2.Text + "'"; SqlCommand pass = new SqlCommand(cmdStr2, con); string password = pass.ExecuteScalar().ToString(); con.Close(); if (password == TextBox2.Text) { Session["New"] = TextBox1.Text; Response.Redirect("Secure.aspx"); } else { Label1.Visible = true; Label1.Text = "Invalid Password!!!"; } } else { Label1.Visible = true; Label1.Text = "Invalid UserName!!!"; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)