I have a problem with the code below:-
When i use a username for example dog for the first time it works but later
when i use cat for example it keeps showing
Hello:- Dog..
It keeps DOG in the session for long.
But i want to get the USERNAME from the datbase and display it
so it catches only the username from the DB only..
I think 'm not placing the "Session["name"] = username.Text; "
CAN ANYBODY ADVICE WHERE I SHOULD PUT THE "SESSION"
Help if u can..PLease..look at the code properly
Thx
void Login_Click(Object sender, EventArgs e)
{
SqlDataReader dr;
SqlConnection cn = new SqlConnection("Data Source=(local);Initial
Catalog=Northwind;Integrated Security=SSPI;");
cn.Open();
SqlCommand cmdQuestion = new SqlCommand("SELECT Password FROM Users WHERE
username = '" + username.Text + "'", cn);
dr=cmdQuestion.ExecuteReader();
if(dr.Read())
if(dr["Password"].ToString() == Password.Text)
// CookieAuthentication.RedirectFromLoginPage(Email.T ext,
false);
Response.Redirect("testlabel.aspx");
else
Msg.Text = "Invalid password.";
else
Msg.Text = "Email address not found.";
Session["name"] = username.Text;
cn.Close();
}