Advertisement
Guest User

Untitled

a guest
Jun 7th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. The C# for the login
  2.  
  3. protected void ButtonLogin_Click(object sender, EventArgs e)
  4. {
  5. {
  6. SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["wedire"].ConnectionString);
  7. conn.Open();
  8. string checkuser = "select count (*) from table_wedire where UserName = '" + TextBoxUname.Text + "'";
  9. SqlCommand com = new SqlCommand(checkuser, conn);
  10. int temp = Convert.ToInt32(com.ExecuteScalar().ToString());
  11. conn.Close();
  12. if (temp == 1)
  13. {
  14. conn.Open();
  15. string checkPasswordQuery = "select UserPass from table_wedire where UserName = '" + TextBoxUname.Text + "'";
  16. SqlCommand passComm = new SqlCommand(checkPasswordQuery, conn);
  17. string password = passComm.ExecuteScalar().ToString().Replace(" ", "");
  18. if (password == TextBoxPass.Text)
  19. {
  20. Session["New"] = TextBoxUname.Text;
  21. Response.Write("Password is correct.");
  22. Response.Redirect("adminpage.aspx");
  23. }
  24. else
  25. {
  26. Response.Write("Password is not correct.");
  27. }
  28. }
  29. else
  30. {
  31. Response.Write("Username is not correct.");
  32. conn.Close();
  33. }
  34.  
  35. }
  36. }
  37.  
  38.  
  39.  
  40. The Web.config file stuff for authorization
  41.  
  42. <location path="adminpage.aspx">
  43. <system.web>
  44. <authorization>
  45. <allow users="wedire" />
  46. <deny users="*" />
  47. </authorization>
  48. </system.web>
  49. </location>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement