PHP Notice: Undefined index, variable

0

I have this error:

PHP Notice:  Undefined index: user in /home/clubbrit/public_html/socios/administrador/header.php on line 6
PHP Notice:  Undefined variable: nombre in /home/clubbrit/public_html/socios/administrador/header.php on line 67
PHP Notice:  Undefined variable: cve_usuario in /home/clubbrit/public_html/socios/administrador/header.php on line 77

This is the code I have in the header:

$usuario=$_SESSION['user']; 
$view->Sociousr=Sociousr::getUsuarioPorClave($usuario); 
foreach ($view->Sociousr as $Usuario):  
$nombre = $Usuario["username"];
$cve_usuario = $Usuario["cve_usuario"];
endforeach; 
    
asked by user5406 25.10.2017 в 20:59
source

1 answer

1

Try not to work with the data of "user" if you are not sure that this has already happened.

Use a condition to execute your sentence

if(isset($_SESSION['user'])){
   $usuario=$_SESSION['user']; 
   $view->Sociousr=Sociousr::getUsuarioPorClave($usuario); 
   //.... continua con tu código
}
    
answered by 25.10.2017 в 21:21