Community, the error I have is that the user to have finished the registration process I want to log it at once without the need to go to a login page, the code I am using for it is the following:
if(isset($_POST) && !empty($_POST)){
$names = $_POST['nombres'];
$pass = $_POST['password_user'];
$nie = $_POST['nie'];
$tlf = $_POST['telefono'];
$email = $_POST['email'];
$d_entrega = $_POST['address_entrega'];
$d_facturacion = $_POST['address_fact'];
$query = "INSERT INTO usuarios (nombres,pass,nie,telefono,direccion_entrega,direccion_facturacion,email)
VALUES ('$names','$pass','$nie','$tlf','$d_entrega','$d_facturacion','$email')";
$sql = $con->query($query);
if($sql>0){
$query2 = "SELECT * FROM usuarios WHERE email = '$email' AND pass = '$pass'";
$sql2 = $con->query($query2);
$result = $sql2->num_rows;
echo $result;
$datos = $sql2->fetch_assoc();
session_start();
$_SESSION['usuario']=$datos;
header('Location:productos.php');
}
}
The num_rows throws to me> 0 but when it does the redirection it sends me to the page without the initiated session. As if it were not logged.