Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perhaps it's the simplest "template"?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi I'm kinda confused ,please read the following solution posted by Jason regarding the template in php

============================================================
Date: 12/15/00 16:44
By: Jason
Subject: My Solution

I am new at this but a simple solution is to use the same PHP
document over and over again but pass a variable which determines
which include document to use. This works very good for personal
home pages. Then you only create one template and plug in the
content you want for each page. Or if you want to redesign and use
the same content you have to only change one document.

For example:

Template PHP document
-------------------------
... HTML ...
<?
if (!$page) {
$page = &quot;index.inc&quot;;
}
include(&quot;$page&quot;);
?>
... HTML ...
-------------------------
To call different documents you can simply form your href's as
follows.
: <a href=&quot;index.php?page=about.inc&quot;>
: About Me</a>
Allowing you to reuse the same layout with different content.

With this setup, each time the PHP document loads you can specify
a new include file, allowing you to only have one document with
many includes. The best part is, you can easily change content
without effecting layout, and can change layout without editing
every content page. Plus, if you include the style sheets in the
index.php you don't have to include formatting in the *.inc
because it will already be specified in the template. This may not
be the best solution for everybody but you would no longer need a
template because you would only need one layout page which would
basically be your template.

============================================================

I'm afraid I don't quite understand what'd he mean, could anyone please explain this in
details? But for sure that there are a number of portals using the same method like:

If possible, kindly please show me the source code of a simple web site which used the method
mentioned above. Thank you very much.
 
In my index.php file, I have this:
<?
swith($ba){
case &quot;home&quot;;
include(&quot;menu.php&quot;);
include(&quot;homepage.php&quot;);
include(&quot;sig.php&quot;);
break;
}
?>
Then I just make my link be index.php?ba=home
you can include all the files you want this way by making more cases like above. You can also put html in the case if you want to customize the look.

Rick If I have helped you just click the first link below to let me know :)
 
Yes, it's true.

But look to one thing, you should NEVER put the complete name of the file. Always skip the extension and put it yourself hardcoded. If you don't, hackers can attack your system easyly.

example,

you have:


i can get anyfile i want just doing this:


or even file=../../../etc/passwd

you can have a big security hole in your system.

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top