New Page 2
  News
Staff
Job Positions
Friends
Contact
News Archive
Shadeslayer Store
Competitions
  Editorials
     
Tialdari Hall
     
The Spine

Eragon
Eldest
Book III
Cover Art
Christopher Paolini
Newsletters
Buy a Copy

Eragon
Cast & Crew
Video Game
Merchandise

Characters
Magic
Dragons
Dragon Riders
Elves
Ra'zac
Shades
Urgals
Ancient Language
Dwarf Language
Urgal Language
Pronunciation
Places
Weaponry

Fan Fiction
Away Messages
Obsessed?
Fake Titles
Fan Profiles

Forums
Galleries

Wallpapers
AIM Icons
Avatars
Themed Music
Comparisons
Webmaster Help


 

PHP Includes

Hypertext Preprocessor (PHP) is a form of server sided HTML-embedded scripting that is increasingly growing in popularity. It can do what most CGI programs can do, such as generate dynamic pages or set cookies. One reason why it's so popular though is its support with a wide range of databases, allowing the programmer to manipulate the script to do what he or she wants. PHP is extremely simple to learn if you know some basic concepts of programming, such as if/then/else, looping and using variables.

However, to use PHP to organize content on webpages, all you need to know is the "include" function. Like in SSI, you are able to link external HTML files into your PHP page. Before you begin this short tutorial, please remember to do two things: check that your server supports PHP, and make sure you upload your pages to your server before testing them out or they will not work as PHP is server-side.

First of all, save your "template" page as a PHP document (change the extention from .htm or .html to .php). For this tutorial, we shall call this PHP page main.php

Open the source code for main.php, and where you want the content to show up put in the following code:

<?php
if (file_exists("$id.htm"))
{include ("$id.htm");}
else
{include ("error.htm");}
?>

Make sure that you also have a HTML containing the content. For this tutorial, we will call it testing.htm. Upload main.php and testing.htm to your server, and locate your file by typing in http://www.yoursite.com/yourfolder/main.php?id=testing. Now here's the hard part to understand.

Think of the term "id" as a variable, like the variable x used in algebra. In the URL, you have just assigned the value "testing" to the variable "id". In the PHP code which you have copied and pasted in to your document, where ever $id occurs (in PHP, a $ denotes a variable), the value "testing" will be replaced instead. So literally, the PHP code is 'including' testing.htm into your PHP page.

Also notice that there is the use of a "if else" statement in the PHP code. What it's saying is that if "$id.htm" exists, then include $id.htm. Otherwise (else), include the error file which is error.htm. In order for that to work, you must have also prepared in advance "error.htm" as your 404 error page.

I hope this has been helpful to you! Please use the contact us form to forward all feedback, comments or questions you might have with PHP includes.

   
   
Legal Disclaimer


Legal Disclaimer
: Shadeslayer.com is an unofficial Inheritance fan site.  We did not create Eragon or any other characters in the Inheritance Cycle.  We have no direct contact with Christopher Paolini, his agents, Random House Press, Fox 2000 or any other related parties.  All content © Shadeslayer.com 2005-2008, unless stated otherwise. Feel free to contact us if you have any questions or concerns.

Shadeslayer.com is non-commercial and hosts advertisements only to pay for hosting, contests and other website-related expenses.

Layout Design by Xaler Studios

PHP Scripting and Coding by Erica


Warning: main(/home/grego18/public_html/shadeslayer/poll/booth.php) [function.main]: failed to open stream: Permission denied in /home/grego18/public_html/shadeslayer/includes/rnav.htm on line 31

Warning: main() [function.include]: Failed opening '/home/grego18/public_html/shadeslayer/poll/booth.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/grego18/public_html/shadeslayer/includes/rnav.htm on line 31

Fatal error: Call to a member function on a non-object in /home/grego18/public_html/shadeslayer/includes/rnav.htm on line 32