Print username when logging in

1

I need some help, I need that when a user loguee I print the username on the welcome page, I've tried several things but I have not yet achieved, here I plan as I have until now. Thank you in advance.

<?php
 session_start();
if(!isset($_SESSION["user_id"]) || $_SESSION["user_id"]==null){
print "<script>alert(\"Acceso invalido!\");window.location='logueo.php';
</script>";
}?>
<!DOCTYPE html>
 <html lang="es">
  <head>
    <meta charset="UTF-8">
    <title>Bienvenido</title>
  </head>
<?php 
 require_once ('conexion.php');
 $id = $_GET['id'];
 $consulta =<<<SQL
 SELECT * FROM usuario WHERE id = '$id'LIMIT 1
 SQL;
 $filas = mysql_query ($consulta);
 $columnas = mysql_fetch_assoc($filas);
?>
<body>
 <?php include "php/navbar.php"; ?>
 <div class="bo">
    <div>
        <center><h2>Bienvenido <?php echo $columnas['fullname'];?></h2></center><br><br>
        <button type="button" class="btn btn-primary btn-lg btn-block" style="position: relative;">COMENZAR</button>
    </div>
  </div>
 </body>
</html>
    
asked by Stivents 14.10.2017 в 20:42
source

1 answer

1
    <?php 
 require_once ('conexion.php');
 $id = $_GET['id'];
 $consulta =<<<SQL
 SELECT * FROM usuario WHERE id = '$id'LIMIT 1
 SQL;
 $filas = mysql_query ($consulta);
 $columnas = mysql_fetch_assoc($filas);
?>

treat this We retrieve the user id from session not from GET

<?php 
    $id = $_SESSION["user_id"];

    $consulta = 'SELECT * FROM usuario WHERE id = $id';
    $controlconsulta = mysql_query($consulta);
    while ($rowuser= mysql_fetch_array($controlconsulta)) {
     $nombrecompleto = $rowuser['fullname'];
    }

echo $nombrecompleto;

?>
    
answered by 14.10.2017 / 20:52
source