Guest User

Untitled

a guest
Sep 11th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. get user specific information from database after login
  2. protected void Button1_Click(object sender, EventArgs e)
  3. {
  4. SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RegConnectionString"].ConnectionString);
  5. con.Open();
  6. string cmdStr = "select count (*) from Registration where UserName ='" + TextBox1.Text + "'";
  7. SqlCommand checkuser = new SqlCommand(cmdStr, con);
  8. int temp = Convert.ToInt32(checkuser.ExecuteScalar().ToString());
  9. if (temp == 1)
  10. {
  11. String cmdStr2 = "select password from Registration where UserName ='" + TextBox1.Text + "'";
  12. SqlCommand pass = new SqlCommand(cmdStr2, con);
  13. String password = pass.ExecuteScalar().ToString();
  14. con.Close();
  15.  
  16. if (password == TextBox2.Text)
  17. {
  18. Session["New"] = TextBox1.Text;
  19. Response.Redirect("secure.aspx");
  20. }
  21. else
  22. {
  23. Label1.Visible = true;
  24. Label1.Text = "Invalid Password....!!!";
  25. }
  26. }
  27. else
  28. {
  29. Label1.Visible = true;
  30. Label1.Text = "Invalid UserName....!!!";
  31. }
  32. }
Add Comment
Please, Sign In to add comment