Affiliates

VibekeFayeAlexx
VesaSabrynaPriya
JuliaQuynhTiff
ApplyRachelLyn

Stats

Daily Views 300+
Host Innocent Sky
online
Site Owner Zoe
Site's Age 3 yrs
Best viewed in Firefox

Ask Me?


See Answers

Advertise







Advertise Here

PHP Tutorial

  • PHP tutorial has been rewritten on the 12/07/09
  • PHP is a file extension that make life a lot easier for coders. Using PHP prevents you from having to put your css and layout on every single page of your site. I use PHP, you may notice PHP in the address bar, for example: www.innocense.org/phptut.php
  • Step 1

    You are going to split your first page into 2 parts and link to both of them on the index page. If that doesn't make sense, hopefully it will soon. Open up notepad and add the following code at the start:

    <link rel=stylesheet href="style.css">

    Now underneath the above code add your layout code and a background code and all of your side bar stuff. Save and name this file header.php (yes you need to type in the .php too) and in the save as file type chose all files option in the drop down menu. So for an example you will now have the following on your header.php page:

    <style> body { background:url("mybackground");} </style>

    <div style="position: absolute; top: 0px; left: 0px;"> <IMG SRC="mylayout" BORDER="0"> </div>

    <div id="side">
    <h1>HEADER</h1>
    This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah.

    <p>

    <h1>HEADER</h1>
    This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah.

    <p>

    <h1>HEADER</h1>
    This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah.

    <p>

    <h1>HEADER</h1>
    This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah.

    <p>

    <h1>HEADER</h1>
    This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah. This is yor side bar stuff, blah blah blah.

    <p>

    </div>

    On your site your header will just be the side bar and look like this

    Step 2

    Now that thats done you need to make a style.css page. Open up a new page in notepad and add ALL of you css minus the style tags which are not necessary. Now save it as "style.css" SO to be clear this is what your style.css page looks like.

    Step 3

    Ok now for the index page and all your content pages for that matter. There are 3 codes that are absolutely essential for this to work. The first one is the one for your css. This makes your css show up on your page, it looks like this:

    <link rel=stylesheet href="style.css">

    You also added the above code to the header page in step 1.

    The next code is the following:

    <?include("header.php");?>

    This makes you sidebar show up.

    The third and last code depends on what is in your css and how you make your css, in my case its the following:

    <div id="innocent">

    This links to the positions and css that were set in the css in the #innocent part in step 2.

    As a reminder, these 3 codes (or at least the first 2) need to be present on all your content pages ie: tutorials, graphics etc.

    On the index page you usually have the 3 above codes and then the code to your blog whether you use cutenews or fanupdate and thats all. Make sure you name this page "index.php" If you are just added a content page to yoursite then after the above 3 codes you may type in your content and whatever as normal and save it as pagename.php

    Step 4

    Ok now upload all pages created via ftp. To recap: you should have header.php, style.css and an index.php page.

    To simplify it a little more basically what you are doing is separating your css and sidebar in 2 files and then linking to both so you only have to change it on one page instead of several. The 3 codes in step 3 dont need to be changed everytime you change layouts, css etc. You can also link to a footer doing the same thing as above but instead of the word header you use footer in step 1. Thats all there is to know. 9 times out of 10 if there is something that doesnt appear correctly when you go to your site its more likely to be a problem with your css not php. If you have any questions let me know.