Hide URL data

2

Hello colleagues, I need to be able to hide the information you sent by URL. I have looked for codes that help me do it but I have not had good results. The Code is:

<?php 
include("obtenerdatos.php");
$user=$_POST['usuario'];
$pass=$_POST['contrasena'];
$ok = 0;
$objeto = new SQLConector;
$lista = $objeto->MostrarUsuario();

for($i =0; $i<count($lista); $i++){
    if($user==$lista[$i]['usuario'] and $pass==$lista[$i]['password']){
        $ok=1; 
        header("Location:bienvenido.php?user=".$user); 
    }   
}
if ($ok==0){
header("Location:invalido.php");
}
?>

What I want to hide is the redirect to header ("Location: bienvenido.php? user=". $ user) since that file sent information to it and is displayed in the URL. Any help will be useful. Regards.

    
asked by Juan Jose Quiroz Moreno 17.08.2016 в 06:51
source

1 answer

3

If you want to hide the user do not send the data through the url, you can use a session to store the user variable, and recover it on your page bienvenido.php , something like this:

<?php 
include("obtenerdatos.php");

session_start();

$user=$_POST['usuario'];
$pass=$_POST['contrasena'];
$ok = 0;
$objeto = new SQLConector;
$lista = $objeto->MostrarUsuario();

for($i =0; $i<count($lista); $i++){
    if($user==$lista[$i]['usuario'] and $pass==$lista[$i]['password']){
        $ok=1; 
        $_SESSION["user"] = $user;
        header("Location:bienvenido.php"); 
    }   
}
if ($ok==0){
  header("Location:invalido.php");
}
?>

And on your welcome.php page you can retrieve it as follows:

<?php
session_start();
$user = $_SESSION["user"];
?>
    
answered by 17.08.2016 / 07:07
source