Trying to display user information after they login
I'm trying to display a users information on a profile page after they get
logged in. Here is the code I'm using:
<?php
require_once('connection.inc.php');
$conn = dbConnect('read');
// get the username's details from the database
$sql = ("SELECT firstname, lastname FROM members WHERE username
='".$_SESSION['username']."'");
$_SESSION['firstname'] = 'firstname';
$_SESSION['lastname'] = 'lastname';
// initialize and prepare statement
$stmt = $conn->stmt_init();
$stmt->prepare($sql);
// bind the result,
$stmt->bind_result($_SESSION['firstname'], $_SESSION['lastname']);
$stmt->execute();
$stmt->fetch();
The code runs without any errors but on the profile page the results get
displayed as: firstname: firstname lastname: lastname
instead of plugging in the information that was supposed to be pulled from
the database.
The display code on the profile page itself is correct, because I can set
the session variables above from the user login page, and they work
properly. I just don't want to be pulling in all that information at
login, if the user isn't going to be doing anything with it. Thanks for
any help.
No comments:
Post a Comment