feelfree82

Untitled

Apr 2nd, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. <?php
  2.  
  3. require_once 'includes/credentials.php';
  4.  
  5. class Mysql {
  6. private $conn;
  7.  
  8. function __construct() {
  9. $this->conn = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or
  10. die('There was a problem connecting to the database.');
  11. }
  12.  
  13. function verify_Username_and_Pass($un, $pwd) {
  14.  
  15. $query = "SELECT hs_memberID, password FROM hs_member WHERE hs_memberID = '$un';";
  16.  
  17. if($stmt = $this->conn->prepare($query)) {
  18. $stmt->bind_param('ss', $un, $pwd);
  19. $stmt->execute();
  20.  
  21. if($stmt->fetch()) {
  22. $stmt->close();
  23. return true;
  24. }
  25. }
  26.  
  27. }
  28. }
  29.  
  30. ================== 2nd file
  31.  
  32. <?php
  33.  
  34. require 'Mysql.php';
  35.  
  36. class Membership {
  37.  
  38. function validate_user($un, $pwd) {
  39. $mysql = New Mysql();
  40. $ensure_credentials = $mysql->verify_Username_and_Pass($un, md5($pwd));
  41.  
  42. if($ensure_credentials) {
  43. $_SESSION['status'] = 'authorized';
  44. header("location: members.php");
  45. } else return "Please enter a correct username and password";
  46.  
  47. }
  48.  
  49. function log_User_Out() {
  50. if(isset($_SESSION['status'])) {
  51. unset($_SESSION['status']);
  52.  
  53. if(isset($_COOKIE[session_name()]))
  54. setcookie(session_name(), '', time() - 1000);
  55. session_destroy();
  56. }
  57. }
  58.  
  59. function confirm_Member() {
  60. session_start();
  61. if($_SESSION['status'] !='authorized') header("location: login.php");
  62. }
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment