Advertisement
Guest User

Untitled

a guest
Feb 11th, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 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.  
  8. public partial class login : System.Web.UI.Page
  9. {
  10. const string fileName = "database.accdb";
  11. protected void Page_Load(object sender, EventArgs e)
  12. {
  13. if (Session["user"] == null && Session["admin"] == null) {
  14. if (Request.Form["submit"] != null) {
  15. string selectQuery = "SELECT * FROM Users WHERE username = '" + Request.Form["username"] + "' AND password = '" + Request.Form["password"] + "' OR email = '" + Request.Form["username"] + "' AND password = '" + Request.Form["password"] + "'";
  16. if (MyAdoHelper.Exist(fileName, selectQuery)) {
  17. string isAdminQuery = "SELECT * FROM Users WHERE username = '" + Request.Form["username"] + "' AND level = 'admin' OR email = '" + Request.Form["email"] + "' AND level = 'admin'";
  18. if (MyAdoHelper.Exist(fileName, isAdminQuery)) {
  19. Session["admin"] = Request.Form["username"];
  20. Response.Redirect("Default.aspx");
  21. Response.End();
  22. }
  23. else {
  24. Session["user"] = Request.Form["username"];
  25. Response.Redirect("Default.aspx");
  26. Response.End();
  27. }
  28. }
  29. else {
  30. Response.Redirect("unsuccessful_login.aspx");
  31. Response.End();
  32. }
  33. }
  34. }
  35. else {
  36. Response.Redirect("Default.aspx");
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement