I have the following logout code:
<?php
require_once 'session.php';
require_once 'User.php';
$user_logout = new User();
if($user_logout->is_loggedin()!="")
{
$user_logout->redirect('./index.php');
}
if(isset($_GET['logout']) && $_GET['logout']=="true")
{
$user_logout->doLogout();
$user_logout->redirect('../../login.php');
}
?>
Where it makes the request for class User.php that holds all the user's functions. Here is the Logout () function:
<?php
require_once './connect/Connect.php';
class User
{
private $conn;
public function __construct()
{
$database = new Database();
$db = $database->dbConnection();
$this->conn = $db;
}
public function runQuery($sql)
{
$stmt = $this->conn->prepare($sql);
return $stmt;
}
public function register($stName, $stUser, $stEmail, $stPhone, $stPassword, $stDepartment, $stLevel, $stAbout)
{
try
{
$new_password = password_hash($stPassword, PASSWORD_DEFAULT);
$stmt = $this->conn->prepare("INSERT INTO
TB001_USUARIO
(TB001_NOME,
TB001_USUARIO,
TB001_EMAIL,
TB001_TELEFONE_1,
TB001_SENHA,
TB002_DEPARTAMENTO_CODIGO,
TB001_LEVEL,
TB001_SOBRE)
VALUES (:name, :user, :email, :phone, :password, :departments, :level, :sobre)");
$stmt->bindparam(":name", $stName);
$stmt->bindparam(":user", $stUser);
$stmt->bindParam(":email", $stEmail);
$stmt->bindParam(":phone", $stPhone);
$stmt->bindParam(":password", $new_password);
$stmt->bindParam(":departments", $stDepartment);
$stmt->bindparam(":level", $stLevel);
$stmt->bindparam(":sobre", $stAbout);
$stmt->execute();
return $stmt;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
public function doLogin($uname,$umail,$upass)
{
try
{
$stmt = $this->conn->prepare("SELECT
TB001_CODIGO,
TB001_USUARIO,
TB001_EMAIL,
TB001_SENHA
FROM
TB001_USUARIO
WHERE
TB001_USUARIO=:uname
OR
TB001_EMAIL=:umail");
$stmt->execute(array(':uname'=>$uname, ':umail'=>$umail));
$userRow=$stmt->fetch(PDO::FETCH_ASSOC);
if($stmt->rowCount() == 1)
{
if(password_verify($upass, $userRow['TB001_SENHA']))
{
$_SESSION['user_session'] = $userRow['TB001_CODIGO'];
return true;
}
else
{
return false;
}
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
public function selectUser()
{
try
{
$stmt = $this->conn->prepare("SELECT
TB001_USUARIO.*,
TB002_DEPARTAMENTO.TB002_NOME
AS
TB002_DEPARTAMENTO_CODIGO
FROM
TB001_USUARIO
INNER JOIN
TB002_DEPARTAMENTO
ON
TB002_DEPARTAMENTO.TB002_CODIGO = TB001_USUARIO.TB002_DEPARTAMENTO_CODIGO;");
$stmt->execute();
return $stmt->fetchAll( PDO::FETCH_ASSOC);
}catch (PDOException $e){
echo $e->getMessage();
}
}
public function update($usersid, $name, $user, $email, $phone, $level, $active, $departments)
{
try
{
$stmt = $this->conn->prepare("UPDATE Users
SET name = :name, user = :user, email = :email, phone = :phone, level = :level, active = :active, departments = :departments
WHERE usersid = :usersid");
$stmt->bindParam(':usersid', $_POST['usersid']);
$stmt->bindParam(':name', $_POST['name']);
$stmt->bindParam(':user', $_POST['user']);
$stmt->bindParam(':email', $_POST['email']);
$stmt->bindParam(':phone', $_POST['phone']);
$stmt->bindParam(':level', $_POST['level']);
$stmt->bindParam(':active', $_POST['active']);
$stmt->bindParam(':departments', $_POST['departments']);
$stmt->execute();
return $stmt;
}catch (PDOException $e){
echo $e->getMessage();
}
}
public function is_loggedin()
{
if(isset($_SESSION['user_session']))
{
return true;
}
}
public function redirect($url)
{
header("Location: $url");
}
public function doLogout()
{
session_destroy();
unset($_SESSION['user_session']);
return true;
}
}
?>
When I click the logout button it displays the following error:
Warning: require_once (./ connect / Connect.php): failed to open stream: No such file or directory in C: \ wamp \ www \ onsistem \ connect \ User \ User.php on line 3
Another application that has the same code is working, it's pretty much the same, does anyone have any idea what the error might be?