How to have index.php load different content

Started by
9 comments, last by MichaelNIII 10 years, 11 months ago

Indeed, sorry I couldnt give decent example code, I was on a phone. Andy's method is what I was refering to.

My index page loading looks like

if ($Page == 'home') {include('MainPage.html');}
else if($Page == 'login') {include('LoginPage.html');}
else if($Page == 'loginsuccess'){include('LoginSuccess.php');}
else if($Page == 'logout') {include('Logout.php');}
else {include('MainPage.html');}

for displaying the different pages, and <li><a href=\"Index.php?Page=login\">Login</a></li> for the different navagation bars. This is a really poor example and could be inproved on a lot, but Eh maybe you will find it more userful then just saying steps, my syntax is ugly as hell but I tend not to worry about my syntax rules until my 2nd or 3rd rewrite for sometime when its less "lets try and get this to work right" and more "lets try and make this modifyable, work right, and easy to read"


<?php
session_start();

echo "<div id=\"navbar\">
<ul>

<li><a href=\"Index.php?Page=home\">Home</a></li>";

if($_SESSION['myusername']==''){echo

"<li><a href=\"Index.php?Page=signup\">Signup</a></li>
<li><a href=\"Index.php?Page=login\">Login</a></li>";}

else{echo
"<li><a href=\"Index.php?Page=logout\">Logout</a></li>";}

echo"
</ul>
</div>
<div id=\"main\">";


echo $_SESSION['myusername'];
echo "<br>";
$Page = $_GET['Page'];

if     ($Page == 'home')        {include('MainPage.html');}

else if($Page == 'login')       {include('LoginPage.html');}
else if($Page == 'loginsuccess'){include('LoginSuccess.php');}
else if($Page == 'logout')      {include('Logout.php');}

else                             {include('MainPage.html');}



echo"</div>";



?>

This topic is closed to new replies.

Advertisement