I need to create a script that records a last-access log in a table, but my insert is not working. I created an Access class, where it logs in.
If anyone can help me. Thank you.
My access class:
class Acesso {
public function run() {
$html = '';
Session::setValue('erro', '');
switch (App::getAction()) {
case 'logout':
$this->logout();
break;
case 'validar':
$this->validar();
break;
default:
$html = $this->login();
break;
}
return $html;
}
public function login() {
$html_login = new Html();
$html = $html_login->load('view/acesso.html');
return $html;
}
public function validar() {
$dados = Connection::select("SELECT login,senha,nome,departamento_id FROM users WHERE login='" . $_POST['usuario'] . "'");
Connection::close();
foreach ($dados as $reg):
if ($_POST['senha'] == $reg['senha']):
Session::setValue('logado', true);
Session::setValue('departamento', $reg['departamento_id']);
Session::setValue('nome', $reg['nome']);
else:
echo "<script>alert('Dados inválidos!'); location.href= 'index.php';</script>";
endif;
endforeach;
$sql = "update log set user_id= user_id, user_data= user_data where id=" . App::$key;
$dados = Connection::exec($sql);
header('Location: ' . URL);
}
public function logout() {
Session::setValue('logado', false);
header('Location: ' . URL);
}
}
When I run, it displays this error below:
Fatal error: Call to a member function exec() on a non-object in