PDA

View Full Version : navigation help



fossils
11-22-2007, 04:10 PM
hi here i want to know some script about navigation

well i have a div tag and it has some texts and links in it, so i want to do is when i click on the link it should open up the link page into this current div...

anybody can help me out please? well if its not possible using PHP please help me in that case also

thank you

Shotgun Ninja
11-22-2007, 05:06 PM
I actually might have an answer for this one!

What I have been using is a XHTML/PHP combo using the following:



<!-- XHTML Form -->
<form name="navForm" action="post" method="navigate.php">
<input type="hidden" name="pageHint" value="" /> <!-- This serves as a buffer to hold the hinted page name -->
<input type="button" value="Home" onClick="javascript:pageHint.value = 'home';" /> <!-- This changes the value of the pageHint field -->
<input type="button" value="About Us" onClick="javascript:pageHint.value = 'aboutus';" /> <!-- This changes the value of the pageHint field as well -->
<!-- ... Fill in as many buttons as you want here, following the examples above -->
<input type="submit" name="navSubmit" value="Go" />
</form>


And the PHP: (navigate.php)


<?php
if (!$_POST['navSubmit'] || !$_POST['pageHint'])
{
die(); // Kill it!
}
$page = $_POST['pageHint'] . '.php'; // Takes the name string (i.e. 'aboutus') and tacks a PHP file extension onto it (i.e. 'aboutus.php')
if (!is_file($page))
{
die(); // Kill it with FIRE!
}
else
{
include($page);
}
?>

fossils
11-23-2007, 08:30 PM
thanks ninja, this will work :)