I'm relatively new to coding. I'm trying to display some of the data the user has saved (when registering) on the next few pages. I can display the username, but I want to display the names and email as well.
this is when the user is logging in.
$query = "SELECT * FROM users
WHERE username='$username'
AND password='$password'";
$results = mysqli_query($db, $query);
if (mysqli_num_rows($results) == 1) {
$_SESSION['username'] = $username;
$_SESSION['success'] = "You are now logged in";
header('location: indexclient.php');
}else {
array_push($errors, "Wrong username/password combination");
}
//new page
//This is the top of the page where I want to display the name.
session_start();
if (!isset($_SESSION['username'])) {
$_SESSION['msg'] = "You must log in first";
header('location: loginclient.php');
}
if (isset($_GET['logout'])) {
session_destroy();
unset($_SESSION['username']);
header("location: loginclient.php");
}
//This is where I want to display the name at the bottom of the page:
<h2> <?php echo $_SESSION['username']; ?>'s Profile</h2>
<?php echo $_SESSION['firstname']; ?>
<?php if (isset($_SESSION['username'])) {
echo "Hello", $_SESSION['firstname'] ;
}