How can i echo the first and last name of the specific user that logs in? Here is my code for checkLogin.php:
$FirstName = $_POST['FirstName'];
$LastName = $_POST['LastName'];
$sql="SELECT * FROM myweekprofiles WHERE LastName='$LastName' and FirstName='$FirstName'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
session_register("FirstName");
session_register("LastName");
header("location:loginSuccess.php");
}else {
//This page will describe that the email/password is incorrect
}
Here is the code for inc_header_User.php:
if(!isset($_SESSION['FirstName'])) {
echo "Hello";
}else{
$FirstName = $_SESSION['FirstName'];
}
I try to echo $FirstName within the header, but i get an error that says:
Undefined variable: FirstName in C:\wamp\www\MyWeek\includes\inc_header_User.php on line 55
session_start();in your page code before trying to call$_SESSION['Firstname']?session_start();before adding anything to the session variable, and you may need to callsession_write_close();at the end of the script.