I'm running a code in PHP and it works totally! It complies with what I ask, but it throws me the following error:
Notice: Undefined index: name in C: \ xampp \ htdocs \ project \ profile.php online 12
What I did was a profile of a login that at the moment of accepting the email with which a user registered, automatically shows his name, and does it perfectly, but that error marks me, this is the code:
<?php
include('classes/DB.php');
include('login.php');
$email = "";
if (isset($_GET['email'])){
$name = isset($_GET['name']) ? $_GET['name'] : '';
if(DB::query('SELECT name, email FROM registroalumnos WHERE email=:email', array(':email'=>$_GET['email']))){
$email = DB::query('SELECT email FROM registroalumnos WHERE email=:email', array(':email'=>$_GET['email']))[0]['email'];
$name = DB::query('SELECT name FROM registroalumnos', array(':name'=>$_GET['name']))[0]['name'];
}else {
die('Usuario no encontrado');
}
}
?>
<!DOCTYPE html>
<html lang="es">
<head>
<title>Perfil</title>
<meta charset="UTF-8">
</head>
<body>
<h1>Perfil de <?php echo $name;?></h1>
</body>
</html>
I already checked the code a lot and I do not know why it causes that.