PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
include_once 'Connect.php';
?>
<html><head>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class=logo><?php include "logo.php";?></div>
<div class=navigationbarbox><?php include "navigationbar.php";?></div>
<div class=welcome>License detilas here</div>
<div class=footerbox><?php include "footer.php";?></div>
</body>
</html>
however i want this page to dispaly another navigationbar if not logged in. i thought i just have to do a call to my is_authed function and then display the correct one
<?php
if (!is_authed())
{
echo "<div class=navigationbarbox><?php include "navigationbar.php";?></div>";
}
else
{
echo "<div class=navigationbarbox><?php include "navigationbar2.php";?></div>";
}
?>
i think the problem is my echo statements can anyone tell me what i should be doing
<?php
if (!is_authed())
{
echo "<div class=navigationbarbox><?php include "navigationbar.php";?></div>";
}
else
{
echo "<div class=navigationbarbox><?php include "navigationbar2.php";?></div>";
}
?>
i think the problem is my echo statements can anyone tell me what i should be doing
You're right, it is your echo statements. You can't use <? and ?> within echo statements because echo statements are, by their nature, already within PHP. You'd need to do this instead:
<?php
if (!is_authed())
{
echo "<div class=navigationbarbox>";
include "navigationbar.php";
echo "</div>";
}
else
{
echo "<div class=navigationbarbox>";
include "navigationbar2.php";
echo "</div>";
}
?>
edit: what do you use to edit your PHP files? if you just use notepad or similar, consider getting a code editor that gives syntax highlighting, and if you use something like NuSphere it even gives you design-time debugging. Makes it much easier to spot errors, as in this case the include() keywords weren't highlighted when they should be, an indicator that they aren't going to work!