I would like a help, I did all the registration and login procedure and it’s working

Asked

Viewed 28 times

-1

I would like a help, I have done all the registration and login procedure and it is working, but I login with email and return me the email(user) on the screen when I login is "hello, [email protected]" that pq I login by email, but wanted to return the name instead of email but continuing the login by email.

<?php
  if(isset($_SESSION['email'])): 
  include('verifica_login.php');
  ?>
  <img id="char" src="IMAGENS/ICONES/char2.ico" alt=""> <br>
  <h2 style="color:white;font-size:13px">Olá, <?php echo $_SESSION['email']; 
  ?></h2>
  <h2 style="color:white;font-size:13px"><a href="logout.php">Sair</a></h2>
  <?php
  endif;
  ?>          

my php file

<?php
session_start();
include('coneccao.php');

if(empty($_POST['email']) || empty($_POST['senha'])){
    header('Location: HOME.php');
    exit();

}

$email = mysqli_real_escape_string($con, $_POST['email']);
$senha = mysqli_real_escape_string($con, $_POST['senha']);

$query = ("select nome from usuario where email = '{$email}' and senha = md5('{$senha}')");

$result = mysqli_query($con,$query);

$row = mysqli_num_rows($result);

if($row == 1){
    $_SESSION['email'] = $email;
    header('Location: HOME.php');
    exit();
}else{
    $_SESSION['nao_autenticado'] = true;
    header('Location: HOME.php');
    exit();
}

?>
  • If you select the database name, why store only the email in the session?

1 answer

0

Replace with this:

<h2 style="color:white;font-size:13px">Olá, <?php echo $_SESSION['nome']; 
?></h2>

and for that reason:

if($row == 1){
    $_SESSION['email'] = $email;
    $_SESSION['nome'] = $row['nome'];
    header('Location: HOME.php');
    exit();
}else{
    $_SESSION['nao_autenticado'] = true;
    header('Location: HOME.php');
    exit();
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.