Guest User

Untitled

a guest
Nov 26th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. HTML PAGE CODE
  2.  
  3. <form id='login' action='login.php' method='post' accept-charset='UTF-8'>
  4. <fieldset >
  5. <legend>Login</legend>
  6. <input type='hidden' name='submitted' id='submitted' value='1'/>
  7.  
  8. <label for='username' >UserName*:</label>
  9. <input type='text' name='username' id='username' maxlength="50" />
  10.  
  11. <label for='password' >Password*:</label>
  12. <input type='password' name='password' id='password' maxlength="50" />
  13.  
  14. <input type='submit' name='Submit' value='Submit' />
  15.  
  16. </fieldset>
  17. </form>
  18.  
  19. //Logging in page code
  20.  
  21. function Login()
  22. {
  23. if(empty($_POST['username']))
  24. {
  25. $this->HandleError("UserName is empty!");
  26. return false;
  27. }
  28.  
  29. if(empty($_POST['password']))
  30. {
  31. $this->HandleError("Password is empty!");
  32. return false;
  33. }
  34.  
  35. $username = trim($_POST['username']);
  36. $password = trim($_POST['password']);
  37.  
  38. if(!$this->CheckLoginInDB($username,$password))
  39. {
  40. return false;
  41. }
  42.  
  43. session_start();
  44.  
  45. $_SESSION[$this->GetLoginSessionVar()] = $username;
  46.  
  47. return true;
  48. }
  49.  
  50.  
  51. lookup page code
  52.  
  53.  
  54. function CheckLoginInDB($username,$password)
  55. {
  56. if(!$this->DBLogin())
  57. {
  58. $this->HandleError("Database login failed!");
  59. return false;
  60. }
  61. $username = $this->SanitizeForSQL($username);
  62. $pwdmd5 = md5($password);
  63. $qry = "Select name, email from $this->tablename ".
  64. " where username='$username' and password='$pwdmd5' ".
  65. " and confirmcode='y'";
  66.  
  67. $result = mysql_query($qry,$this->connection);
  68.  
  69. if(!$result || mysql_num_rows($result) <= 0)
  70. {
  71. $this->HandleError("Error logging in. ".
  72. "The username or password does not match");
  73. return false;
  74. }
  75. return true;
  76. }
  77.  
  78.  
  79.  
  80.  
  81. access control page code
  82.  
  83.  
  84. <?PHP
  85. require_once("./include/membersite_config.php");
  86.  
  87. if(!$fgmembersite->CheckLogin())
  88. {
  89. $fgmembersite->RedirectToURL("login.php");
  90. exit;
  91. }
  92. ?>
  93.  
  94.  
  95.  
  96. CheckLogin() function code
  97.  
  98.  
  99. function CheckLogin()
  100. {
  101. session_start();
  102.  
  103. $sessionvar = $this->GetLoginSessionVar();
  104.  
  105. if(empty($_SESSION[$sessionvar]))
  106. {
  107. return false;
  108. }
  109. return true;
  110. }
Add Comment
Please, Sign In to add comment