/    Sign up×
Community /Pin to ProfileBookmark

Making things visible based on user level and echoing username..

I need help fixing this, I am pretty new to php. So far what I have is a user table with; userid, username, password, email, and user_level(for setting user/admin). I want to make it so certain things show for everyone logged in or not, then different things for users/admins. I also want to echo the username where the login button normally is on the home page.

Here is what I have–

[code=html]<!DOCTYPE html>
<html>
<?php include “base.php”; ?>
<head>
<title> Scenery Sample Site | Home</title>
<link href=’http://fonts.googleapis.com/css?family=Lobster’ rel=’stylesheet’ type=’text/css’>
<link href=”css/bootstrap.css” rel=”stylesheet”>
<link href=”css/main.css” rel=”stylesheet”>
</head>

<div class=”nav”>
<div class=”container”>
<ul class=”pull-left”>
<li><a href=”index.html”>Home</a></li>
<li><a href=”#”>About Us</a></li>
<li><a href=”#”>Pricing</a></li>
<li><a href=”#”>Feedback</a></li>
</ul>
<ul class=”pull-right”>
[code=php]
<?php
if($_SESSION[‘user_level’] == 1) {
echo “Hello $username”;
}
?>
[/code]

</ul>
</div>

</div>

<div class=”jumbotron”>
<div class=”container”>
<h1>Scenery for your favourite<br> destinations!</h1>
<p>Learn more about our products by clicking the link below.</p>
<p><a href=”products.html”>Visit our product page.</a></p>
</div>
</div>

<div class=”we-offer”>
<div class=”container”>
<div class=”col-md-4″>
<h3>Custom Building Models!</h3>
<p>All of our scenery models are custom made by our developers.</p>
<p><a>More Details Here!</a></p>
</div>
<div class= “col-md-4”>
<h3>State of The Art Texturing!</h3>
<p>All of our scenery textures are custom, and of the highest quality. You will have to make sure you’re not watching real life.</p>
<p><a>More Details Here!</a></p>
</div>
<div class=”col-md-4″>
<h3>Moving Jet-ways!</h3>
<p>A lot of competitors remove the functionality of moving jetways that fsx comes with. Well guess what, we don’t!</p>
<p><a>More Details Here!</a></p>
</div>
</div>
<div class=”container”>
<div class=”col-md-4″>
<div class= “thumbnail”>
<img src=”http://goo.gl/ZRT5E6“>
</div>
</div>
<div class= “col-md-4”>
<div class= “thumbnail”>
<img src=”http://goo.gl/KsocGR“>
</div>
</div>
<div class=”col-md-4″>
<div class= “thumbnail”>
<img src=”http://goo.gl/3UfG97“>
</div>
</div>
</div>
</div>

</html>[/code]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 03.2015 — You will need a call to session_start(); before anything gets output, including anything (even spaces or newlines) not within <?php ?> tags.
×

Success!

Help @aaronstran spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...