Guest User

Untitled

a guest
Jul 4th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Data.SqlClient;
  8. using System.Configuration;
  9.  
  10. public partial class Login : System.Web.UI.Page
  11. {
  12. protected void Page_Load(object sender, EventArgs e)
  13. {
  14. SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["PagConnectionString"].ConnectionString);
  15. con.Open();
  16. string cmdStr = "Select count(*) from Registration where Username=";
  17. cmdStr = cmdStr + "";
  18. cmdStr = cmdStr + TextBoxUN.Text;
  19. cmdStr = cmdStr + "";
  20. SqlCommand CheckUser = new SqlCommand(cmdStr, con);
  21. int temp = Convert.ToInt32(CheckUser.ExecuteScalar().ToString());
  22. if ( temp== 1)
  23. {
  24. string cmdStr2 = "Select Password from Registration where Username=" + TextBox2.Text + "";
  25. SqlCommand pass = new SqlCommand(cmdStr2, con);
  26. string password = pass.ExecuteScalar().ToString();
  27. con.Close();
  28.  
  29. if (password == TextBox2.Text)
  30. {
  31. Session["New"] = TextBoxUN.Text;
  32. Response.Redirect("Secure.aspx");
  33. }
  34. else
  35. {
  36. Label1.Visible = true;
  37. Label1.Text = "Invalid Password";
  38. }
  39. }
  40. else
  41. {
  42.  
  43. Label1.Visible = true;
  44. Label1.Text = "Invalid Username";
  45. }
  46. }
  47. }
Add Comment
Please, Sign In to add comment