0
Good afternoon. I’m trying to implement on a page PHP a welcome message after a login. I would like to display the name of the user who has just logged in through a variable php. The login screen requires the email and password registered in the database. I stored each of the two in a SESSION to authenticate. On the following page I want the NAME, I know that it is necessary to search for this name in the database passing as parameter the email that the user logged in and storing in a variable (query mysql). I tried to do so:
$busca = "SELECT Nome FROM newsletter WHERE Email = '$_SESSION['Email']'";
$result = mysqli_query($conexao, $busca) or die("Falha");
Compiler returns the error:
Parse error: syntax error, Unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting Identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C: xampp htdocs Blog php areavip.php on line 14
I managed to get around this error by taking this SESSION and storing it in another variable, leaving the code like this:
$email = $_SESSION['Email'];
$busca = "SELECT Nome FROM newsletter WHERE Email = '$email'";
$result = mysqli_query($conexao, $busca) or die("Falha");
The problem is when I used an echo to display what was stored in the variable it returns:
SELECT Nome FROM newsletter WHERE Email = '[email protected]'.
The email has been stored, but it returns every query as a string. Before using this command I tested it in Workbench to see if the return of the search was expected and there ta all right the problem is somewhere in this script but I could not find.