PHP Tutorial

PHP is a neat little trick that lets your change your layout without having to edit every single page of your site. It's not complicated and is very handy. Before you convert to PHP make sure your host supports PHP or it won't work. REMEMBER!: Geocities, Angelfire, etc. don't have PHP support! So don't bother me about that.

Step 1: Take all your pages of content and delete all the layouts tags, and just leave the body part with the content in it. Change the extention from .shtml or whatever you had to .html, Also remove any SSI you have on your page, you won't need it anymore. Once you did this, take just your layout code and put it in notepad or whatever PHP Editor you'd like to use. Now here's the tricky parts.

Step 2: Make sure to re-add your navigation links and anything else you used to use SSI for back into your layout. You should not need SSI anymore. 

*If your wondering how to insert news into your page with PHP like Newspro, look at the bottom of the tutorial to learn how.

Step 3: With just your layout HTML code with everything on it except the content part, into notepad or whatever your using for PHP. Insert this code where your content was:

Remember to edit this to the following or it won't work! In the "$page.extension" part, you can change the "page" to anything you'd like for example "szl". Make sure that you change the "extension" part to the extensions of your content pages. For example if your content pages are .html files you'd put ".html" after "$page". So in all it would be "$page.html". This code tells the browser to load the specified page in your PHP page. Now save this as main.php or whatever you'd like the PHP page to be called.

Step 4: Now test it, upload the PHP page to your server and 1 page of content that you cleaned on Step 1. Now punch in the address into your browser, for example http://www.yoursite.com/index2.php?whatever=page. This is probably the hardest thing of all. Here's what each mean to clear up any questions:

Lets use http://yoursite.com/main.php?id=news

main.php or whatever you named it: The main PHP page that has the entire layout in it expect the content part
"whatever" or what you chose in your PHP code: Change "id" to what you choose in your PHP code inside your PHP page, for example "szl.html".

"news": The file name of the content page you want to load, in this example the news page is being loaded. Remember don't type in .html extension or something else, just the file name.

"?": Remember the question mark after your PHP page name in your browser.

See how on this site, the page name is "id.html" so for example this page your on now loads as "main.php?id=php-tutorial". This is tricky and so don't give up if you get an error loaded on your php page.

All right! Now you should have PHP fully working! Remember to change your links to whatever you choose to named your PHP page and plus the extension to the page. If you don't see shit, check your code again and make sure your server supports PHP, if your not sure, ask your host or check their FAQ if they have one. Good luck with your site!

Extra Tips

Inserting Newspro into your PHP Site
Once you have your PHP working, make a page for your News like news.html. Once you've done that, on your News page insert this code to include Newspro into your site.



Remember to change "pathto/news.txt" to where your news.txt is located at on your server. Once your done your news should load when you go to your news page.