Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'includes/credentials.php';
- class Mysql {
- private $conn;
- function __construct() {
- $this->conn = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or
- die('There was a problem connecting to the database.');
- }
- function verify_Username_and_Pass($un, $pwd) {
- $query = "SELECT hs_memberID, password FROM hs_member WHERE hs_memberID = '$un';";
- if($stmt = $this->conn->prepare($query)) {
- $stmt->bind_param('ss', $un, $pwd);
- $stmt->execute();
- if($stmt->fetch()) {
- $stmt->close();
- return true;
- }
- }
- }
- }
- ================== 2nd file
- <?php
- require 'Mysql.php';
- class Membership {
- function validate_user($un, $pwd) {
- $mysql = New Mysql();
- $ensure_credentials = $mysql->verify_Username_and_Pass($un, md5($pwd));
- if($ensure_credentials) {
- $_SESSION['status'] = 'authorized';
- header("location: members.php");
- } else return "Please enter a correct username and password";
- }
- function log_User_Out() {
- if(isset($_SESSION['status'])) {
- unset($_SESSION['status']);
- if(isset($_COOKIE[session_name()]))
- setcookie(session_name(), '', time() - 1000);
- session_destroy();
- }
- }
- function confirm_Member() {
- session_start();
- if($_SESSION['status'] !='authorized') header("location: login.php");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment