I have two user types. Some who signup on the site and some who sigh up with facebook.
If the user signup with facebook i'm loading the profile picture. The problem is that i only want to load a picture if they come from facebook, and my code so far doesn't load the content after my elseif statement
<body>
<!-- After user login -->
<?php if ($_SESSION['Femail']): ?>
<div class="container">
<div class="hero-unit">
<h1>Hello <?php echo $_SESSION['FIRST_NAME']; ?></h1>
</div>
<div class="span4">
<?php elseif ($_SESSION['FBID']): ?>
<img src="https://graph.facebook.com/<?php echo $_SESSION['FBID']; ?>/picture">
<div>
<div id="userProfile">
</div>
<a href="logout.php">Log out</a>
</div>
</div>
<?php else: ?>
<h3>Not logged in</h3>
<?php endif ?>
</body>
How do i load the profile picuture in my elseif statement without ending my first if statement?
Just add another if
-endif
pair, like this:
<body>
<!-- After user login -->
<?php if ($_SESSION['Femail']): ?>
<div class="container">
<div class="hero-unit">
<h1>Hello <?php echo $_SESSION['FIRST_NAME']; ?></h1>
</div>
<div class="span4">
<?php if ($_SESSION['FBID']): ?>
<img src="https://graph.facebook.com/<?php echo $_SESSION['FBID']; ?>/picture">
<?php endif; ?>
<div>
<div id="userProfile">
</div>
<a href="logout.php">Log out</a>
</div>
</div>
<?php else: ?>
<h3>Not logged in</h3>
<?php endif; ?>
</body>
You can nest control statements as deeply as you like.
"All users has have the session 'Femail'"
Remove the elseif
and replace it with a regular if
, otherwise the elseif
block will never execute because "All users has have the session 'Femail'
"