I have a question, how do I get the id of the guy who logged in on my system? So that later he can change his data.
<?php
if (isset ($_POST ["loginUsuario_externo"])){
include_once("../controllers/Usuario_Externo_Controller.php");
$usuario_externo = new Usuario_externo_Controller;
$usuario_externo->login();
}
Login function
public function login() {
$this->usuario_externos->email($this->input->get('email'))
->senha($this->input->get('senha'));
$resultado = $this->usuario_externos->login();
if($resultado) {
session_start();
$_SESSION['login'] = $resultado;
echo '<script>window.location = "../views/externo/";</script>';
echo ('Aguarde, redirecionando.');
} else {
echo ('E-mail ou Senha incorreto(os).');
}
}
MODEL
public function login() {
$sql = "SELECT * FROM usuario WHERE email = :email AND senha = :senha AND status = 1 LIMIT 1";
$stmt = $this->conn->prepare($sql);
$stmt->bindParam(':email', $this->email, PDO::PARAM_INT);
$stmt->bindParam(':senha', $this->senha, PDO::PARAM_STR);
$stmt->execute();
return $stmt->fetch();
}
starta session and vrf if there is session
<?php
session_start();
function session_checker(){
if (! isset($_SESSION['login'])){
header ("Location:../");
exit();
}
}
session_checker();
?>