-2
I have the page below:
<?php
require_once '../config.php';
require_once 'config.php';
?>
<!doctype html>
<html>
<head>
<meta charset='utf-8'>
<title><?php echo $constantes->getTituloSite(); ?> - Administração - Login</title>
</head>
<body>
<?php
if (isset ($_SESSION["login"])) require_once "home.php";
else {
echo '<div id=login>
<form action="?" method="post">
<input type="hidden" name="logar" />
<input type="text" name="login" id="login" required placeholder="Usuário" />
<input type="password" name="senha" id="senha" required placeholder="Senha" />
<input type="submit" value="Entrar" />
</form>
</div>';
}
if (isset($_POST["logar"])) {
print_r($_POST);
$administradoresDao = new AdministradoresDao();
$administradoresDao->buscarTodos ("WHERE login='" . $_POST["login"] . "' AND senha = '" . $_POST["senha"] . "'");
$administradoresModelos = new AdministradoresModelos();
}
?>
</body>
</html>
I’m having the following problem:
Note that you have 2 configs
required at the outset.
In the middle of the page, notice that I have a
$administradoresDao = new AdministradoresDao();
The first required config.php brings access to the database among other things.
The second brings only:
<?php
use classes\mvc\modelos\AdministradoresModelos;
use classes\mvc\modelos\AdministradoresDao;
?>
The problem is this:
When I put the block:
if (isset($_POST["logar"])) {
Inside the page config.php
lowly:
<?php
use classes\mvc\modelos\AdministradoresModelos;
use classes\mvc\modelos\AdministradoresDao;
if (isset($_POST["logar"])) {
print_r($_POST);
$administradoresDao = new AdministradoresDao();
$administradoresDao->buscarTodos ("WHERE login='" . $_POST["login"] . "' AND senha = '" . $_POST["senha"] . "'");
$administradoresModelos = new AdministradoresModelos();
};
?>
Class is normally loaded.
But if I leave where it is or, pasme, put below the require of the same class, it gives that the class was not loaded!
Where is the error?
where you do the autoload require?
– gmsantos
at the root... using Poser. Top so, the config file is found normally because if I put the object inside the Casse loads, but it obviably gives error because I still do not have the form data!
– Carlos Rocha
so, the use is in the context of the file, I think if you put it inside the require will not roll even
– gmsantos
yeah, I decided to throw it out and remove the include. However, the previous require has use and works well on the page!
– Carlos Rocha
where exactly? in the file you put as an example you only prompted two classes...
– gmsantos
2 requires de config.php, right? One, the top one, is at the root and also has the use clause. This I can quietly call an object whose use is in it. But the bottom config I can’t. So I had to call the use directly on the body
– Carlos Rocha