Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 04-17-2009, 09:09 PM PHP engine
Novice Talker

Posts: 6
Trades: 0
Hello! Maybe someone can help me? i need a very simple php web engine. i don't want have all category index files like files.php links.php, i want have only 1 index.php and all category information are in text documents or someone else. sorry for bad english
hobbyhall is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-17-2009, 11:36 PM Re: PHP engine
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
How's this for a basic driver?

PHP Code:
<?php
$active_page 
'home';
if (!empty(
$_GET['page'])) {
  
$desired_page preg_replace('/[^a-z0-9\-\_]/i','',$_GET['page']);
  if (
file_exists($desired_page.'.html')) {
    
$active_page $desired_page;
  }
}
include 
$active_page.'.html';
?>
URLS are of the form index.php?page=XXX where a file called XXX.html must exist in the same directory as the HTML file.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 04-18-2009, 06:46 AM Re: PHP engine
Novice Talker

Posts: 6
Trades: 0
I understand this code needs to be in index.php file, thanks a lot you are the best, but i have 1 question, i need to xxx.html, xxx2.html information open in some <table> what i want :| how i can add to table?
sorry for stupid question, im just a newbie

Last edited by hobbyhall; 04-18-2009 at 06:48 AM..
hobbyhall is offline
Reply With Quote
View Public Profile
 
Old 04-18-2009, 11:00 AM Re: PHP engine
nayes84's Avatar
Extreme Talker

Latest Blog Post:
Difference between ASP And JSP
Posts: 232
Name: John
Location: Tokyo
Trades: 0
in that case you will need to display table tags just before including the pages
for example:
PHP Code:

<html>
<head>
</head>
<body>
<table><tr><td>
 <?php
$active_page 
'home';
if (!empty(
$_GET['page'])) {
  
$desired_page preg_replace('/[^a-z0-9\-\_]/i','',$_GET['page']);
  if (
file_exists($desired_page.'.html')) {
    
$active_page $desired_page;
  }
}

include 
$active_page.'.html';
?>  
</td></tr></table>
</body>
</html>
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

if(I'm("Helpful")) Add_Talkupation("nayes84");
nayes84 is offline
Reply With Quote
View Public Profile
 
Old 04-19-2009, 05:24 PM Re: PHP engine
Novice Talker

Posts: 6
Trades: 0
sorry im realy stupid
i create index.php and in index.php i put only this code
Code:
<?php
$active_page = 'home';
if (!empty($_GET['page'])) {
$desired_page = preg_replace('/[^a-z0-9\-\_]/i','',$_GET['page']);
 if (file_exists($desired_page.'.html')) {
$active_page = $desired_page;
 }
}
 
include $active_page.'.html';
?>  
and i have home.html with site design. right?
and i create xxx.html with some text only
when i go to this link localhost/index.php?page=xxx i don't see changes and i don't see tekst from xxx.html
from what line of this code reading the file xxx.html xxx2.html......
thanks for helping

Last edited by hobbyhall; 04-19-2009 at 07:32 PM..
hobbyhall is offline
Reply With Quote
View Public Profile
 
Old 04-20-2009, 04:11 AM Re: PHP engine
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
May be a language barrier, but I'm not totally getting what you're saying.

Can you post a small set of, say 2 or 3, files showing what you've tried?
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 04-20-2009, 05:40 AM Re: PHP engine
Novice Talker

Posts: 6
Trades: 0
ok let's begin:
i have index.php and in index.php i have only this lines:
Quote:
<?php
$active_page = 'home';
if (!empty($_GET['page'])) {
$desired_page = preg_replace('/[^a-z0-9\-\_]/i','',$_GET['page']);
if (file_exists($desired_page.'.html')) {
$active_page = $desired_page;
}
}

include $active_page.'.html';
?>
right?

second i have home.html and in home.html i have all website design, but not this lines:
Quote:
<?php
$active_page = 'home';
if (!empty($_GET['page'])) {
$desired_page = preg_replace('/[^a-z0-9\-\_]/i','',$_GET['page']);
if (file_exists($desired_page.'.html')) {
$active_page = $desired_page;
}
}

include $active_page.'.html';
?>
right?

and i have xxx.html only with some text, and when i go to url localhost/index.php?page=xxx I don't see text from xxx.html. Why?
hobbyhall is offline
Reply With Quote
View Public Profile
 
Old 04-20-2009, 06:42 PM Re: PHP engine
Novice Talker

Posts: 6
Trades: 0
please give answer someone
hobbyhall is offline
Reply With Quote
View Public Profile
 
Old 04-20-2009, 07:13 PM Re: PHP engine
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
I'm having problems with my localhost server and running a chkdsk on the system. Sorry, but you'll have to wait until that comp is back up for me to help.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 04-21-2009, 03:46 PM Re: PHP engine
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
I have attached a file which demonstrates exactly what I wrote above. Hopefully this will help you figure out what went wrong.
Attached Files
File Type: zip basic_template.zip (1.2 KB, 1 views)
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 04-21-2009, 03:47 PM Re: PHP engine
Average Talker

Posts: 19
Trades: 0
what is the difference between this and using singular files like home.html, about.html, etc.?
rogerchin85 is offline
Reply With Quote
View Public Profile
 
Old 04-21-2009, 04:13 PM Re: PHP engine
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
In this setup, nothing. Usually what one would want to do is separate the template from the content. That gives you the added advantage of being able to change the layout without affecting the content.

The attached file provides an example of the type of structure I'm talking about.
Attached Files
File Type: zip basic_template_extended.zip (2.5 KB, 1 views)
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Reply     « Reply to PHP engine
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.45619 seconds with 13 queries