Click here to Skip to main content
15,910,358 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have 2 text boxes Email text box and password text box, all i need is when i clik on login button it signin, as i m a begginer help me with login code.
Posted

Take the values in email and password textbox
check the database if it contains any record whose email and password match with the values given in textboxes
if record exists then redirect the user to respective page
 
Share this answer
 
you can use login for as on login button click event
C#
string str = "select * from empbirth where UserID=@userid and password=@pass";
            SqlConnection cnn=new SqlConnection();
            cnn.ConnectionString="Your connection string";
            cnn.Open();
            SqlCommand cmd = new SqlCommand(str, cnn);
            cmd.Parameters.AddWithValue("userid", txtUId.Text);
            cmd.Parameters.AddWithValue("pass", txtpwd.Text);
            SqlDataReader dr = cmd.ExecuteReader();

            if (dr.Read())
            {
               //take any action
            }
else
{
Response.Write("INVALID ATTEMPT");
}
 
Share this answer
 
v2
Comments
rkthiyagarajan 17-Sep-11 4:46am    
Good Ans...
Asad_Iqbal 20-Sep-11 3:27am    
That code helps me alot bro, now can u help me with logout code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900