0
Well I was in the same trouble of that question, gave an answer to use define('ROOT_PATH', dirname(__FILE__));
, (my problem without using this solution) but in mine it does not work.
The following error is shown::
Warning: Use of Undefined Constant DIRETORIO - assumed 'DIRETORIO' (this will throw an Error in a Future version of PHP) in C: wamp64 www php_pdo view Sign-in.php on line 27
index php.:
<php
define('DIRETORIO', dirname(__DIR__));
...
Sign-in.php:
<?php
if($_POST){
$usuario = filter_input(INPUT_POST, 'usuario', FILTER_SANITIZE_STRING);
$senha = filter_input(INPUT_POST, 'senha', FILTER_SANITIZE_STRING);
require_once DIRETORIO . '/controller/logincontroller.php'; // linha 27
LoginController::logar($usuario, $senha);
}
I tried to do what that answer suggests, but gave in the same.
Sign-in.php
<?php
if($_POST){
$usuario = filter_input(INPUT_POST, 'usuario', FILTER_SANITIZE_STRING);
$senha = filter_input(INPUT_POST, 'senha', FILTER_SANITIZE_STRING);
require_once '../index.php';
require_once DIRETORIO . '/controller/logincontroller.php'; // linha 27
LoginController::logar($usuario, $senha);
}
It is not enough to add the constant in a file, it is necessary to use the
require
to include the archive with the constant in the aruqivosign-in.php
. Avoid using../index.php
or similar, prefer to use the full file path/path/to/index.php
orc:/path/to/index.php
– Valdeir Psr
Thank you, I thought the variables created by
define
were global.– Leandro