我可以让用户登录,但我如何将他们的信息转移到其他页面?我想$thisUser
保留对所有信息的查询
$query = "SELECT * FROM users WHERE username = ? AND password = ? LIMIT 1";
下面是我的登录代码。
<?php
require_once 'includes\constants.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 conecting to the database.');
}
function verify_username_and_pass($un, $pwd) {
$query = "SELECT * FROM users WHERE username = ? AND password = ? LIMIT 1";
if($stmt = $this->conn->prepare($query)){
$stmt->bind_param('ss',$un,$pwd);
$stmt->execute();
if($stmt->fetch()) {
$stmt->close();
return true;
}
}
}
}
<?php
require 'classes\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: index.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() - 10000 );
session_destroy();
}
}
}