-5
I’m new in web development, I took a course and I’m using as a base the site we developed there.
But some things I still don’t understand well and I’m having trouble pulling the field nome
database.
The connection is correct, but I don’t know how to do it.
<?php
if(!isset($_SESSION)){
//redirecionamento
header('location: index.php');
}
$email = $_SESSION['email'];
$senha = $_SESSION['senha'];
$consulta = $conexao->query('select id,nome,data_nascimento,email,senha from cadastro where email="'.$email.'" and senha=md5("'.$senha.'")');
$lista=$consulta->fetch(PDO::FETCH_ASSOC);
echo'<br>';
echo'<main id="conteudo1">';
echo'<p>Bem-Vinda, ','nome','!</p>';
echo'</main>';
?>
You have to worry about SQL injection, see How an SQL Injection Happens? and How to prevent SQL code injection into my PHP code?. Also see What is the best way to create a PHP login system and take a look at the documentation examples of PHP Pdostatement::fetchAll()
– Augusto Vasques