Hello, I'm trying to get the user ID displayed in the url when it logs in. I made a function that receives the login and password of the user and returns the ID. But when the user logs in, the ID that shows in the URL is always '0'. Regardless of which users log in.
index.php
<form method="POST" action="conteudo.php" name="logar">
<fieldset>
<label>
<input type="text" name="usuario" placeholder="LOGIN"/>
</label>
<br><br>
<label>
<input type="password" name="pass" placeholder="SENHA"/>
</label><br><br>
<input type="submit" name="enviar" value="ACESSAR"/>
<input type="submit" name="cadastrar" value="CADASTRAR"/>
</fieldset>
</form>
content.php
if($_POST['enviar']){
$login = $_POST['usuario'];
$senha = sha1($_POST['pass']);
if(verificaUsuario($conexao,$login,$senha)){
$id = pegandoID($conexao,$login,$senha);
header("Location: principal.php?id={$id}");PASSANDO ID PARA URL AQUI
}elseif(!verificaUsuario($conexao,$login,$senha)){
header("Location:index1.php?erro=#");
}
}elseif($_POST['cadastrar']){
header("Location: cadastro.php");
}
banco.php
include "config/config.php";
try{
$conexao = new PDO("mysql:host={$servidor};port=3306;dbname={$banco}",$usuario,$senha);
}catch(PDOException $error){
echo "Erro: " . $error->getMessage() . "<br>";
die();
}function pegandoID($conexao,$login,$senha){
$sql = $conexao->exec("SELECT id FROM usuarios WHERE login='$login' AND senha='$senha'");
return $sql;}