Changing navigation bar/header based on log in

0 Sean Peoples · September 2, 2014
Hi all!

Just been playing about with some PHP recently. Been tinkering with a small football database I created and have been stumped for a while.
I've been trying to have code on the home page (index.php) after the login page(login.php) that determines what header shows up. For example
If the user's email is 1@hello.com, then it will show the header "Players | Teams | Update Statistics | Logout"
If the user's email is 2@hello.com, then it will show the header "Players | Teams | Logout"

I've attempted some code, using sessions and others, but couldn't figure it out.

The last code I attempted was: 
.....
   if(isset($_POST['email']))
    $userid = ($_POST['email']);
    if($userid = 1)
    {
        require_once('adminHeader.php');
    }
    else
    {
        require_once('header.php');
    }

.....
I'm only new so don't be throwing complicated words at me.. Lol :) Any help would be appreciated!

Post a Reply

Replies

Oldest  Newest  Rating
+2 Alan Johnson · September 5, 2014
To check for equality you need to use ==
You could also use === to check that values are equal and of the same type.

Change
if($userid = 1)


To
if($userid == 1)
0 Shamal Sandeep · September 5, 2014
if ($userid == 1) {
will fix that remember a single equation assigns a value to a variable. double equal sign compares two digits or two strings(non-case sensitive). 3 equation sign matches with case.
  • 1

PHP

106,954 followers
About

Server-side, HTML embedded scripting language used to create dynamic Web pages.

Links
Moderators