Thursday, February 4, 2010

LOGIN PAGE

for example

protected void Button1_Click(object sender, EventArgs e)
{
string lname, pword;
lname = txtlogin.Text;
pword = txtpassword.Text;
cmd = new SqlCommand("select firstname,lastname,loginname,password from user_info where loginname = @lname",conn);
cmd.Parameters.Add("lname", txtlogin.Text);
conn.Open();
dr = cmd.ExecuteReader();
dr.Read();
if (lname == dr.GetString(2).Trim() && pword == dr.GetString(3).Trim())
{
Statuslabel.Text = "You have Successfully login!!!!";
Session["firstname"] = dr.GetString(0);
Session["lastname"] = dr.GetString(1);
Response.Redirect("allinone.aspx");
}
else
{
Statuslabel.Text = "Plz,enter correct login name and password...";
}
conn.Close();
}

No comments:

Post a Comment