I have a my navbar script on a file called navbar.php. I include this file at the top of all other pages of my website. What I am trying to do now is to customize the navbar with the name of whoever is logged in. Let's say I have a php file named account-process.php with a variable $name = 'Bob'
. I'm having trouble making this variable show up in the navbar.
Here's my account-process.php:
<?PHP
//VARS: gets user input from previous sign in page and assigns it to local variables
//$_POST['signin-email'];
//$_POST['signin-pass'];
$signin_email = $_POST['signin-email'];
$signin_pass = $_POST['signin-pass'];
// connects to MySQL database
include("config.inc.php");
$link = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db($db_name,$link);
// checking for user input in the table
$result = mysql_query("SELECT * FROM table WHERE email = '$signin_email' AND password = '$signin_pass'");
if (mysql_num_rows($result) > 0) { // if the username and password exist and match in the table
echo "Account Found";
$account_arr = mysql_fetch_array($result); // contains all the data from the user's MySQL row
echo print_r($account_arr);
}
else { // if username and password don't match or they aren't found in the table
echo "The email or password you entered is incorrect.";
}
?>
I'm trying to access the $account_arr
variable in navbar.php so I can display the user's name on the top. I have tried including account-process.php in navbar.php with <?php include('account-process.php') ?>
and then accessing the variable in the html of the navbar, but the page simply turns out blank when I attempt this.
navbar.php simply has basic scripting for a fixed navbar with some information. Why does it turn blank when I try to include the php file in it?
Thanks