Site hosted by Angelfire.com: Build your free website today!
New Namek / PHP Tutorial

PHP is short for "PHP: Hypertext Preprocessor". PHP is a tool that lets you create dynamic web pages. PHP-enabled web pages are treated just like regular HTML pages and you can create and edit them the same way you normally create regular HTML pages.

Ok, PHP is very very simple and easy to learn. I'm just going to teach you how to use PHP's advantages with layouts, as there is much much more to PHP than what I'm about to teach you. Here goes. Follow carefully and you'll learn this in no time.

Step 1:
Ensure that your host supports PHP. Most free hosts like Geocities, Angelfire, Homestead and Tripod, do not support PHP. If your host does support PHP, move on to Step 2.

Step 2:
Create a page using HTML with all your tags, as you usually would when making a site's main page.

Step 3:
Now comes the fun part. Delete everything that is in the table where the main content would go. Once deleted type the following PHP code into where the content was:

Now, the $variable.extension is a variable you will use for your pages, for them to be tracked down in your site. You can replace $variable with anything you want. I replaced $variable with $page, just for ease of use and rememberance, but it's your choice. Now, the $extension is the extension of the files you are going to use for all your content pages. The most common extensions are .html and .txt, as they are the easiest to edit. So, once you have decided what variable and extension you are going to use, move on to Step 4.

Step 4:
Now for the PHP coding to work, you must save that page as a .php file. Name it something simple, as it will be used all over your site (like main.php), so let's pretend you've named it main.php. Now upload the PHP file to your web space. If you access main.php through your web browser, you will see your site's layout, but a PHP error message in the content table. That is because you've not directed it to any page on your site. Move on to Step 5!

Step 5:
Now you'll need a page for main.php to direct to. To do this you'll have to make a page in a certain way, which is very simple. Seeing as though your main.php has already got the layout's tags included in the page, all you need to put into the new page is something like this:


Now save this page as whatever.ext. Replace .ext with the extension you decided to insert in the PHP code on main.php. Then upload this page to your web space. Now, to get to whatever.ext using main.php, you will have to use this kind of link:

http://www.yourdomain.com/main.php?variable=whatever

Just replace variable with the variable you decided to insert in the PHP code on main.php. You will then see that the main.php has linked up with whatever.html to make 1 page. You might now be understanding what PHP is used for in layouts. The main.php is kind of like a template which has all the layout's tags in them, while the other pages are the content pages which fit into the page. Pretty neat, eh? Just imagine how easy it is to edit the look of your layout or change your layout! you don't have to worry about edit ALL the pages, you just have to edit that one PHP page! Have fun now!

PHP Tips

Q: Ok, I understand everything above, but how do I get newspro to show on one of the pages?
A: Well, what you must do is create a page, name it something like news.php, and in news.php, type out this code:

or wherever your news.txt resides. The same goes with Coranto users.
Q: Great! Now I see that your newspro/coranto appears on main.php. How do you do that?
A: Just insert the following code to your PHP file right at the very top of the page, even above the tag:

Now just replace $variable with whatever you decided to insert in your PHP Code, and replace news with whatever page you're newspro code is on. Simple!