umair mohsin

umair mohsin

  • 1.3k
  • 348
  • 55.9k

Login page issue

May 1 2017 6:10 PM
here is my complete code.i am basically making a login page in which a user which is not  registered should given a detailed message and those who are registered should send to their profile page i didn't get the idea how to play this game although i am trying alot for this and logically my code is correct but still not working please help me out in it.
 
 
string constr = ConfigurationManager.ConnectionStrings["JPConstr"].ConnectionString;
using (SqlConnection conn = new SqlConnection(constr))
{
conn.Open();
SqlCommand cmd = new SqlCommand("select UserId,Password from Sign_Up where UserId=@Id", conn);
cmd.Parameters.AddWithValue("@Id", txtlogin.Text);
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
string User = rdr["UserId"].ToString();
string password = rdr["Password"].ToString();
if (password == txtpassword.Text)
{
Page.Session.Add("user", txtlogin.Text);
Page.Session.Timeout = 20;
Response.Redirect("Profile.aspx?id=success");
}
else if (txtlogin.Text!=User && txtpassword.Text != password)
{
Label3.Text = "Invalid user id or password";
Label3.ForeColor = System.Drawing.Color.Blue;
}
//if (txtlogin.Text!=UserId)
//{
// Label3.Text = "crazy password or user id";
// Label3.ForeColor = System.Drawing.Color.Purple;
//}
else
{
Label3.Text = "Invalid user id or password login with valid account or sign up to register";
Label3.ForeColor = System.Drawing.Color.Red;
}
}
conn.Close();
 

Answers (5)