Here is my code.
index.php
Code: Select all
<?php
include(dirname(__FILE__) . '/controller/config.php');
$new = new New();
$new->run();Code: Select all
<?php
define("MYSQLI_HOST", "localhost");
define("MYSQLI_USERNAME", "username");
define("MYSQLI_PASSWORD", "password");
define("MYSQLI_DATABASE", "database");
define("GUEST_EMAIL", "guest@localhost");
define("WEBSITE_TITLE", "");
if(version_compare(PHP_VERSION, "5.2.0", ">")) {
class New {
function run() {
include('user.php');
$User = new User();
$User->view();
}
}
} else {
echo "Sorry, but your PHP Version is less than 5.2.0. Please update your PHP Version so that you are able to use this application.";
}Code: Select all
<?php
class User extends New {
function view() {
session_start();
$_SESSION['email'] = "test@test.com";
// Since email IS set, then the email will output test@test.com, but when you use session_destroy(); here
// you'll get guest@localhost
echo $_SESSION['email'] . "<br />";
if(isset($_SESSION['email'])) {
if(GUEST_EMAIL == $_SESSION['email']) {
echo GUEST_EMAIL;
} else {
$GET_USERS_DATABASE = new mysqli(MYSQLI_HOST, MYSQLI_USERNAME, MYSQLI_PASSWORD, MYSQLI_DATABASE);
if($GET_USERS_DATABASE->connect_errno) {
echo "Error, failed to connect to MySQL database. Please fix.";
exit();
}
$GET_USERS = $GET_USERS_DATABASE->prepare("SELECT id, firstname, lastname, email FROM users WHERE email = ? LIMIT 1");
$GET_USERS->bind_param("s", $SESSION_EMAIL);
$SESSION_EMAIL = filter_var($_SESSION['email'], FILTER_SANITIZE_STRING);
$GET_USERS->execute();
$GET_USERS->bind_result($GET_U_ID, $GET_U_FIRSTNAME, $GET_U_LASTNAME, $GET_U_EMAIL);
while($GET_USERS->fetch()) {
$GET_U_IDS = $GET_U_ID;
$GET_U_FIRSTNAMES = $GET_U_FIRSTNAME;
$GET_U_LASTNAMES = $GET_U_LASTNAME;
$GET_U_EMAILS = $GET_U_EMAIL;
}
$this->id = $GET_U_IDS;
$this->firstname = $GET_U_FIRSTNAMES;
$this->lastname = $GET_U_LASTNAMES;
$this->email = $GET_U_EMAILS;
echo $this->id . ": " . ucfirst($this->firstname);
if($this->lastname == "") {
} else {
echo " " . ucfirst($this->lastname);
}
echo " - " . $this->email;
}
} else {
echo GUEST_EMAIL;
}
}
}
[text]: - [/text]
as the output. Nothing was put in there, but at the same time, the session email is set.
Can anyone help me figure this out?