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 concon = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); concon.Open(); string cmdstr = "Select count (*) from registration where Username='" + TextBox1.Text + "'"; SqlCommand checkuser = new SqlCommand(cmdstr, concon); int temp = Convert.ToInt32(checkuser.ExecuteScalar().ToString()); if (temp == 1) { string cmdstr2 = "Select Password from registration where Username='" + TextBox1.Text + "'"; SqlCommand pass = new SqlCommand(cmdstr2, concon); string password = pass.ExecuteScalar().ToString(); if (password == TextBox2.Text) { Session["new1"] = 0; Session["new5"] = TextBox1.Text; Response.Redirect ("f1.aspx" ); } else { concon.Close(); Label1.Visible = true; Label1.Text = "Invalid Password"; } } else { concon.Close(); Label1.Visible = true; Label1.Text = "Invalid UserName"; } } protected void Button2_Click(object sender, EventArgs e) { } }