|
Let's say you want to create a dynamic ContactUs module that displays either e-mail or mailing address information. You want the following URLs to work:
Here's a file that does that: <?php if (!eregi("modules.php", $_SERVER['PHP_SELF'])) { die ("You can't access this file directly..."); } $module_name = basename(dirname(__FILE__)); $index = 1; function snailmail() { global $module_name; include("header.php"); OpenTable(); echo "Our address is:"; CloseTable(); include("footer.php"); } function email() { global $module_name; include("header.php"); OpenTable(); echo "Our e-mail address is:"; CloseTable(); include("footer.php"); } function MainMenu() { global $module_name; include("header.php"); OpenTable(); echo "Which do you want?<br><br>"; echo "<ul>"; echo "<li><a href=\"modules.php?name=$module_name&which=email\">E-Mail Address</a>"; echo "<li><a href=\"modules.php?name=$module_name&which=mail\">Mailing Address</a>"; echo "</ul>"; CloseTable(); include("footer.php"); } switch($which) { default: MainMenu(); break; case "mail": snailmail(); break; case "email": email(); break; } ?> Notice some common bits of each function:
|
|