Help
Search
Login
Register
Home
Forum: web design and graphics community
Celestial Star Forum
>
Web Development
>
Coding
>
Tutorial: PHP include
Pages: [
1
]
2
« previous
next »
Print
Author
Topic: Tutorial: PHP include (Read 4807 times)
Michelle
Retribution
Posts: 153
Tutorial: PHP include
«
on:
July 26, 2004, 10:53:04 AM »
Heya^^ Okay I made this tutorial on another forum a while back, but since I hardly go to it anymore, I decided "oh what the hell" and decided to post it here too, for anyone who wanted to learn ^^
First off, you cannot be on a free server such as Geocities, Freewebs, Angelfire, Tripod etc. You have to be hosted somewhere where PHP is installed and allowed.
Once you know that your site is able to support PHP then its time for you to learn your basic PHP codes:
<? include('top.php'); ?>
and
<? include('bottom.php'); ?>
Its quite easy to understand, you place this code
<? include('top.php'); ?>
at the very top and place this code
<? include('bottom.php'); ?>
at the very bottom ^^
Now, you must have your links of the layout at the top of the HTML code. Its basically taking the uppper whole part of the layout. I'll explain, here is the HTML code for a layout that I have made and I'll divide the parts for you:
<!--- START TOP.PHP --->
<html>
<head>
<title>Linear Disillusion</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<META HTTP-EQUIV="imagetoolbar" CONTENT="no">
<table width="600" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="600">
<img src="images/image.gif"></td>
</tr>
</table>
<div style="position:absolute; width:174; left:81; top:350; border:0px none;">
<!---MENU STARTS--->
<p class="header" align="right">Information</p>
+ <a href="http://">Link Here</a><br>
+ <a href="http://">Link Here</a><br>
+ <a href="http://">Link Here</a><br>
+ <a href="http://">Link Here</a><br>
+ <a href="http://">Link Here</a><br>
<p class="header" align="right">Information</p>
+ <a href="http://">Link Here</a><br>
+ <a href="http://">Link Here</a><br>
+ <a href="http://">Link Here</a><br>
+ <a href="http://">Link Here</a><br>
+ <a href="http://">Link Here</a><br>
<p class="header" align="right">Information</p>
+ <a href="http://">Link Here</a><br>
+ <a href="http://">Link Here</a><br>
+ <a href="http://">Link Here</a><br>
+ <a href="http://">Link Here</a><br>
+ <a href="http://">Link Here</a><br>
<p class="header" align="right">Information</p>
+ <a href="http://">Link Here</a><br>
+ <a href="http://">Link Here</a><br>
+ <a href="http://">Link Here</a><br>
+ <a href="http://">Link Here</a><br>
+ <a href="http://">Link Here</a><br>
<p class="header" align="right">Information</p>
+ <a href="http://">Link Here</a><br>
+ <a href="http://">Link Here</a><br>
+ <a href="http://">Link Here</a><br>
+ <a href="http://">Link Here</a><br>
+ <a href="http://">Link Here</a><br>
<p class="header" align="right">Credits</p>
<center>Site ? Your Name. Layout ? 2003 <a target="_blank" href="http://sw.my-fault.net">Silver Winds</a>. All Rights Reserved.
</center>
<!---MENU ENDS--->
</div>
<div style="position:absolute; width:355; left:262; top:320; border:0px none">
<!---END TOP.PHP --->
<!--- START INDEX.PHP --->
<!---CONTENTS STARTS--->
<p class="header" align="right">About This Layout</p>
<p class="content" align="justify">
This layout features Magna Carta. Its a DIV Layers layout, which means its very basic and easy to edit. If you need intructions on how to install this layout, please contact me at: minagi@my-fault.net.</p>
<p class="header" align="right">Layout Credits/Copyrights</p>
<p class="content" align="justify">
This layout and all else is © Minagi of <a href="http://sw.my-fault.net">Silver Winds</a>. The image is from <a href="http://boyis.com">Boyis.com</a>!<p>
There is a link located at the bottom of this layout, please do NOT remove it.
<!---CONTENTS ENDS--->
<!--- END INDEX.PHP --->
<!---START BOTTOM.PHP--->
</div>
</BODY>
</HTML>
<!---END BOTTOM.PHP--->
Thats it, all you do is cut it up, take the top.php html and put it ony a seperate page then name it top.php, do the same with the index.php put it on a different page then name it index.php it is where all of your content will go. The bottom.php is put on a different page also its usually where you put your credits but for this layout the credits are in the navigation, don't forget to name the page bottom.php.
Now on your index.php page you should have this (im still using the layout above)
<? include('top.php'); ?>
<!---CONTENTS STARTS--->
<p class="header" align="right">About This Layout</p>
<p class="content" align="justify">
This layout features Magna Carta. Its a DIV Layers layout, which means its very basic and easy to edit. If you need intructions on how to install this layout, please contact me at: minagi@my-fault.net.</p>
<p class="header" align="right">Layout Credits/Copyrights</p>
<p class="content" align="justify">
This layout and all else is © Minagi of <a href="http://sw.my-fault.net">Silver Winds</a>. The image is from <a href="http://boyis.com">Boyis.com</a>!<p>
There is a link located at the bottom of this layout, please do NOT remove it.
<!---CONTENTS ENDS--->
<? include('bottom.php'); ?>
I hope that helped, if you still have questions or your confused just email or PM me. Or simply just reply, and I'll hopefully be able to answer your question.
Logged
Frozen
Observation
Posts: 277
Tutorial: PHP include
«
Reply #1 on:
July 28, 2004, 04:21:56 AM »
oi oi! I'll have to read this! But I cant right now ^^;
Logged
img]http://img25.exs.cx/img25/1235/Vanishing_Dreams.jpg[/img]
Melfina
Administrator
Valkyrie Randgris
Posts: 1289
Tutorial: PHP include
«
Reply #2 on:
July 28, 2004, 12:44:21 PM »
It took me quite long to learn this ;_; If I had read your tutorial I'm sure it would have been easier >.<
Logged
MySpace
~
MySpace Codex
~
Rune Nifelheim
sugarbyte
Angeling
Posts: 6
Tutorial: PHP include
«
Reply #3 on:
August 10, 2004, 06:29:34 PM »
Ok, im REALLY new to php and im sooooo eager to learn! but I still don't understand how youre supposed to connect two pages together. Do you think you could simplify some stuff ?.. I don't understand also how php works and what its " purpose" is... for example css would apply to the whole page... what is php's purpose? And When you save the document made on notepad... do you save it as a .php? Thanks! 8)
Logged
img]http://hl2maps.ansiibomber.ch/sugarbyte/sigbase1.gif[/img]
Do not fear what lies ahead....
Melfina
Administrator
Valkyrie Randgris
Posts: 1289
Tutorial: PHP include
«
Reply #4 on:
August 10, 2004, 07:44:37 PM »
Hmm... let's see... I'll try to explain it as well as I can, and I think that won't be much ><
PHP is just different from html. It's another language, though, of course, you can use html in it. It's mostly used to make mySQL connections and such.
This tutorial is about the
php include
function. What that does is breaking your normal html page into 3 parts: the top part of your html common on all pages, the content part and the other bottom part of your layout that is also common in all pages.
If you use html... what happens if you want to change a link from your navigation?? you need to change ALL the pages (unless you use iframes). To avoid this we use php include that keeps the common code on all pages in a sepparate file (that can be of many extensions: .txt, .php, .inc ...) and call it in all content pages with this code:
<? include('file.php'); ?>
...So let's say that you want to display a piece of code on all pages and you want to be able to edit it many times... you don't want to edit all pages everytime... well, we would write that piece of code in notepad (this is just a simple example, you would do that with the whole layout):
<a href="whatever"><img src="image.gif" border="0"></a>
We would save that as file.php. But... how do we display that piece of code on the pages? just placing this code in the pages in the place you want that displayed:
<? include('file.php'); ?>
What would happen doing that is that it would automatically add that piece of code that's saved in file.php into your pages. The only condition is that all pages need to have the .php extension in order to work the include.
Maybe you can try reading the tutorial again now to see if you understand something else now :S
This is a really baaaaaaaaaaaaaaaaaaaaaad explanation... I can't even understand it myself ><
Logged
MySpace
~
MySpace Codex
~
Rune Nifelheim
sugarbyte
Angeling
Posts: 6
Tutorial: PHP include
«
Reply #5 on:
August 10, 2004, 09:34:25 PM »
Thanks so much! It makes alot more sense now!! ^___^
Logged
img]http://hl2maps.ansiibomber.ch/sugarbyte/sigbase1.gif[/img]
Do not fear what lies ahead....
Stolen Pixelite
Incubus
Posts: 62
Tutorial: PHP include
«
Reply #6 on:
August 23, 2004, 07:15:48 PM »
The include(); function will just make the requested file be included with that file. It helps if you want to have a cleaner php code. It also helps to have a better template system, like easier to change layouts or something like that. My site for instance doesnt do that... but it makes the coding look much cleaner and easier to read.
Sometimes you dont have to have the parenthesis. it can be
Code:
<? include 'file.php'; ?>
Yet you still need the ";" as it parses it. without it you will get a parse error >.<
Logged
:wub: PHP.
meganduong
Angeling
Posts: 1
Tutorial: PHP include
«
Reply #7 on:
April 26, 2006, 08:11:20 PM »
This is a really great tutorial. One thing I am still confused about is where would you upload your images that you're gonna be using for your layout?
Logged
Blackstone
Administrator
Valkyrie Randgris
Posts: 821
Oh look! People!
Tutorial: PHP include
«
Reply #8 on:
May 01, 2006, 12:35:54 PM »
There are plenty of places that you can upload images at.
http://www.photobucket.com
is just one of them. ^^ It's the one I use most of the time, but if you ask around, I'm sure other people can refer you to others. =)
Logged
mizuiro
Angeling
Posts: 13
mizuiro
Re: Tutorial: PHP include
«
Reply #9 on:
June 04, 2007, 07:01:46 AM »
Quote from: meganduong on April 26, 2006, 08:11:20 PM
This is a really great tutorial. One thing I am still confused about is where would you upload your images that you're gonna be using for your layout?
You might want to try out the following free image hosting (other than Photobucket):
ImageCave
ImageShack
If this small list doesn't satisfy you, you can try checking out these pages:
http://www.free-webhosts.com/free-image-hosting.php
http://www.absolutely-free-hosting.com/free_photo_hosting.php
Logged
digitalwings
Solace
Posts: 132
Re: Tutorial: PHP include
«
Reply #10 on:
July 03, 2007, 07:00:05 AM »
Am I official in love with this tutorial1 I have been trying for quite some time now to get a hang of this PHP thing. Michelle , you clarified it so well. I will tell everyone who wants help with PHP about this tutorial!
Logged
Zukin
Angeling
Posts: 8
:3
Re: Tutorial: PHP include
«
Reply #11 on:
October 23, 2007, 05:43:00 PM »
I don`t know about php, but i want to learn. I understand this. But that link calls a php code?
Logged
El Alma tiene ilusiones como el ave las alas.. eso es lo que la sostiene...
+:My art:+
+:My videos:+
Blackstone
Administrator
Valkyrie Randgris
Posts: 821
Oh look! People!
Re: Tutorial: PHP include
«
Reply #12 on:
October 23, 2007, 11:19:20 PM »
What link would you be talking about?
Logged
sandra2018
Angeling
Posts: 2
Re: Tutorial: PHP include
«
Reply #13 on:
December 06, 2007, 01:46:11 PM »
just wondering how does the whole layout thing work once you are done? and how can u use divs in this instead of tables?
Logged
venice
Angeling
Posts: 9
live.laugh.love
Re: Tutorial: PHP include
«
Reply #14 on:
February 26, 2008, 07:21:45 AM »
i'm already done with my layout.. i labeled it index.html.. so if i open it with notepad, there's a bit of a code there.. will i replace that code with your codes?
Logged
Pages: [
1
]
2
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> General
=> New Members
=> Announcements
=> Support / Suggestions
-----------------------------
Contests
-----------------------------
=> Archive
===> Contests
===> Blend Challenges
===> SOTW
-----------------------------
Art Boards
-----------------------------
=> Creative mediums
=> Requests & offers
=> Tutorials
===> Celestial Star Tutorials
-----------------------------
Web Development
-----------------------------
=> Coding
=> Web Design
=> Advertisements / Affiliation
-----------------------------
Off-topic
-----------------------------
=> Entertainment
-----------------------------
Español (Spanish Only)
-----------------------------
=> General / Bienvenida
=> Anuncios / Ayuda
=> Código / Desarrollo web
Welcome,
Guest
Members login
Register for free
General
General
New members
Announcements
Support / Suggestions
Art boards
Creative mediums
Requests and offers
Tutorials
Celestial Star tutorials
Web development
Coding
Web design
Advertisements / affiliation
Off-topic
The non-sense
Ententainment
Loading...