Display a user's name in their profile. PHP

0

Good morning, have all of you!

I'm making a user platform and I'm in the profile phase, I've already logged in (which, you enter by registered mail), registration, use of cookies, password forgotten, etc ...

Now, my PHP code for the profile is that it has the TRUE email, otherwise it would show "unregistered user":

    <?php include('classes/DB.php');
include('login.php');

$email = "";
 if (isset($_GET['email'])){
    if(DB::query('SELECT 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'];

    }else {
        die('Usuario no encontrado');
    }

 }

?>

With this code, it takes the email, but apart from taking it, I also want you to take the NAME of the user with that email and it is displayed in:

<h1>Perfil de <?php echo $name; ?></h1>

In my database it is saved in "name". What else should be added in the code to show the name?

PS: I still do not apply JS, I'm in the functionality. Thanks.

    
asked by Antonio Alejos 02.02.2018 в 15:38
source

2 answers

1

If you already show the $ email of the session just make a query to your database using the email as a reference.

And that way you bring the name of the profile.

I hope it serves you Greetings

    
answered by 03.02.2018 / 17:48
source
0

Why do not you use PHP's $ session? PHP session

Once you have validated, you save it in the php session variable.

session_start();
$_SESSION["newsession"]=$value;

echo $_SESSION["newsession"];

and so you make use of this throughout the application. obviously declaring the session_start () before making use of $ _SESSION ["variable"];

I hope your answer will help.

    
answered by 02.02.2018 в 16:02