-1
require_once('conexao.php');
@$email = $_POST['email'];
@$senha = md5($_POST['senha']);
// $email = "[email protected]";
// $senha = "12346";
$pdo = $dbconn->prepare("SELECT userid, nome, nivel FROM usuario WHERE email=:email and senha=:senha");
$pdo->bindParam(":email", $email);
$pdo->bindParam(":senha", $senha);
$pdo->execute();
// print_r ($pdo);
$users = $pdo->fetchAll(PDO::FETCH_ASSOC);
if (count($users) <= 0)
{
echo "<script>alert('Email ou senha errados');
top.location.href='./index.php';
</script>";
exit;
}
// pega o primeiro usuário
$user = $users[0];
session_start();
$_SESSION['logged_in'] = true;
$_SESSION['userid'] = $user['userid'];
$_SESSION['username'] = $user['nome'];
$_SESSION['usernivel'] = $user['nivel'];
// print_r ($_SESSION);
// echo session_id();
header('Location: ./_link/link.php');
I want to return the id
on another page to make a insert
at the bank
session_start();
print_r($_SESSION);
if(!$_SESSION) {
header("Location: .././index.php");
exit;
}
who would that id?
– user60252
The id of the user table, which I pulled for the session. On another page I want to link the user to make the Insert in the database
– Renan Araújo
would be the value of
userid
?– user60252
That’s right, I want the other page to receive this id so that the Insert will be linked to this user
– Renan Araújo
You already possess his value,
$_SESSION['userid']
put this in a variable on the page of the Insert$variavel = $_SESSION['userid']
don’t forget thesession_start();
– user60252
Note that
$_SESSION
shows all session variable values for a user session– user60252