| 
	
 | 
 Posted by thetechturf.com on 05/25/07 10:34 
I have some simple dynamic content pages (included below). I need to 
know how to add specific meta tags (ie. description, keywords, ect.), 
as well as extra specific header coding to a page. I would like to 
have these on the Links page. Is this possible? and how? 
------------------------------------------------------------------------------------------------------------------------------ 
index.php 
--------------- 
<?php 
// Assign the requested page to a shorter variable for simplicity. 
// The value of $_GET["page"] will be obtained from index.php? 
page=RIGHT_HERE 
$p = $_GET["page"]; 
// Check for bad requests. This is necessary to prevent the wrong 
files 
// from being included. This is a security measure. 
if (strpos($p,"..")) { 
    // A bad request has been made, exit immediately. Do not proceed 
    // with the inclusion. 
    //  strpos($p,"..") checks for presence of ".." in the page 
request. 
    //   ".." can be used to access files in parent directories 
    die("Bad page request"); 
} 
// File to include. 
// this will be something like '/www/page.php'. If $p is empty, fall 
back 
// main.php. THIS FILE MUST EXIST, otherwise bad things will happen. 
if (!$p) $p = "main"; 
$content_file=$_SERVER["DOCUMENT_ROOT"]."/".$p.".php"; 
// See if $content_file exists. If it does not, redirect to the 
homepage. 
if (!file_exists($content_file)) { 
    header("Location: {$_SERVER["PHP_SELF"]}"); 
    exit(); 
} 
// At this point everything is fine. Set the appropriate title and 
then 
// include the files. 
// Syntax: $variable = (condition) ? value_if_true : value_if_false; 
$title = ($p) ? "$p - My Site!" : "Main page - My Site!"; 
include("header.php"); 
include($content_file); 
include("footer.php"); 
?> 
 
--------------------------------------------------------------------------------------------- 
header.php 
---------------- 
<html> 
<head> 
<title><?=$title ?></title> 
<style type="text/css"> 
<!-- 
body { 
    background-color: white; 
    color: #333333; 
    font-family: verdana; 
    font-size: 11px; 
} 
--> 
</style> 
-------------------------------------------------------------------------------------------- 
links.php 
------------ 
[meta description] 
[extra javascript special for this page] 
<p> 
This is my links page. Notice there is no header or footer inclusion 
in this 
file. There are no links here at the moment. 
</p> 
-------------------------------------------------------------------------------------------------
 
  
Navigation:
[Reply to this message] 
 |