01.
using
System;
02.
using
System.Collections.Generic;
03.
using
System.Linq;
04.
using
System.Web;
05.
using
System.Web.UI;
06.
using
System.Web.UI.WebControls;
07.
using
System.Data.SqlClient;
08.
using
System.Configuration;
09.
10.
public
partial
class
Login : System.Web.UI.Page
11.
{
12.
protected
void
Page_Load(
object
sender, EventArgs e)
13.
{
14.
15.
}
16.
protected
void
Button1_Click(
object
sender, EventArgs e)
17.
{
18.
SqlConnection con =
new
SqlConnection(ConfigurationManager.ConnectionStrings[
"RegConnectionString"
].ConnectionString);
19.
con.Open();
20.
string
cmdstr =
"Select count(*) from Registration where UserName='"
+ TextBox1.Text +
"'"
;
21.
SqlCommand checkuser =
new
SqlCommand(cmdstr, con);
22.
int
temp = Convert.ToInt32(checkuser.ExecuteScalar().ToString());
23.
if
(temp == 1)
24.
{
25.
string
cmdstr2 =
"Select Password from Registration where UserName='"
+ TextBox1.Text +
"'"
;
26.
SqlCommand pass =
new
SqlCommand(cmdstr2, con);
27.
string
password = pass.ExecuteScalar().ToString();
28.
con.Close();
29.
30.
if
(password == TextBox2.Text)
31.
{
32.
Session[
"New"
] = TextBox1.Text;
33.
Response.Redirect(
"Secure.aspx"
);
34.
35.
}
36.
else
37.
{
38.
Label1.Visible =
true
;
39.
Label1.Text =
"Invalid Password...!!"
;
40.
}
41.
}
42.
else
43.
{
44.
Label1.Visible =
true
;
45.
Label1.Text =
"Invalid UserName...!!"
;
46.
}
47.
48.
}
49.
}