Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 



Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > Design Forum > Web Design & Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Web Design & Programming Discussion of web design, and server-side & client-side scripting

Reply
 
LinkBack Thread Tools
Old 09-16-2007, 07:59 PM   #1 (permalink)
Registered User
 
Join Date: Jan 2007
Posts: 108
OS: window XP


Create php Web site using template

I would like to know how to create a customizable php web site that using a template.

I did create a php web site before that using a template. The logic for the web site is like this:

1) First, I create a web template. Example, the name is "template.php"
2) Then I create the main page content for the web site named "main.php".
3) Then I create an index file. File name is "index.php".

So, It work like this. In the index.php, it will include the file main.php and template.php.


Example code for template.php

<html>

<head>

<title>New Page 1</title>
</head>

<body>

<table border="0" width="100%" height="32">
<tr>
<td width="100%" height="7">banner here</td>
</tr>
<tr>
<td width="100%" height="13"> <?php include($content); ?> </td>
</tr>
</table>

</body>

</html>


Example code for main.php

<html>

<head>

<title>main page</title>
</head>

<body>
Here is the content for main page



</body>

</html>



Example code for index.php:

<?php

$content = "main.php";

include("template.php");

?>


------------------------------------
This site work well if you have a few page for your site. If your page increase, we need to add php swith command to the index page. But that is

the inefficient come, if your page content hundred of page, then need to add hundred of php switch command to check which page to load.


So, any others way to create a customizable web site that using template?

Hope you guy can understand
peterjcs is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Important Information
Join the #1 Tech Support Forum Today - It's Totally Free!

TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free.

Join TechSupportforum.com Today - Click Here

Old 09-18-2007, 04:44 AM   #2 (permalink)
Design Team Member
 
Redcore's Avatar
 
Join Date: Aug 2007
Location: Jamestown, CA
Posts: 718
OS: Linux Mint 7

My System

Re: Create php Web site using template

You can call the content up through a variable. I do this on my website and other sites that I've made, actually.

So you can make it like this: index.php?p=contact

contact.php is pulled into the middle of the page. At the top of index.php, I put this:

PHP Code:
<? if(!$p){$p='home';} 

// clean up the page variable if someone is trying to abuse it
$remove = array(
"http""www"".com"".net"".org"".tk"".nl"".br"".ru"".tv"".mobi"".co.uk"".php"".php3"".php4"".php5"".txt"".html"":""/""."","
);
$p str_replace($remove""$p);
?>
Notice that clean-up process. This will keep people from abusing your variable, like doing this: index.php?p=http://www.naughtysite.com/badscript.txt"

People could do the above and basically take over your server. So that's why we clean up the variable and get rid of everything in "$remove" ... it's also a good idea to turn "allow_url_fopen" off so people can't open malicious text files through an off-site URL. Ensure that you've modified "open_basedir" as well - it should be set for your account, that way nobody can execute a script that is not on your server/account.

Okay, so where you have the include, this is what I do:
PHP Code:
<? include $p.".php"?>
Notice the ".php" - it's cleaner to have the link as "index.php?p=contact" rather than "?p=contact.php" and it doesn't give anybody any ideas to try to link to their own PHP file or another file (especially malicious ones)

I hope you get what I'm throwin' at ya ;)
Redcore is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-19-2007, 01:47 AM   #3 (permalink)
Registered User
 
Join Date: Jan 2007
Posts: 108
OS: window XP


Re: Create php Web site using template

Thank redcore. I will try it.
peterjcs is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 05:13 PM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85