Zymic Forums

Webmaster resources

Zymic IRC Server

Chat in real time at irc.zymic.com - Learn More

Welcome

Welcome to the Zymic webmaster forums. Our forums are here to provide people the free ability to discuss a range of websites related topics such as design, development coding and marketing.

In order to post you will need to register for a zymic account or if you already have one simply login by using the form on the left.

left Zymic Webmaster ForumsWeb Design & DevelopmentServer Side ScriptingPHP right
  Reply to this topic Start new topic
left right
Earpy
post Oct 23 2007, 11:11 AM
Post #1


Newbie
*

Group: Members
Posts: 27
Joined: 19-September 07
From: England, United Kingdom
Member No.: 121



Hey guys,

I am looking for a little bit of support. My current aim is to have a script which will call a page and add it to a template. For example, I have a page called page1.html and that page only contains html, which I then want to include into the template by typing in http://www.somedomain.com/index.php?page=page1.html. If the page exists, it will include it, otherwise it will redirect to a error page. Anybody give me some tips, or even better a script which would do this? (Sorry if i sound as if I am stealing scripts)

Thanks in advance for any help,
Earpy
Go to the top of the page 
 
  + Quote Post
MrTouz
post Oct 23 2007, 01:52 PM
Post #2


Outrageously Uber Ninja
*******

Group: Members
Posts: 1,196
Joined: 19-September 07
Member No.: 234



i have that script... problem is its implanted inside PHPBB3 ive been trying to take it off to make it work inside a simple site...

example of what it does : http://www.allroundelites.com/community/page.php?page=home

you dont need to put the .html behind the page=

only problem with my script is that i dont have a else { so if you give a wrong url it just makes somthing ugly.

Ill try once more tonight to take this code out and past it here if anyone is whilling to correct it for you ?
Go to the top of the page 
 
  + Quote Post
Alex
post Oct 23 2007, 02:05 PM
Post #3


zIRC Network Admin
*******

Group: Administrators
Posts: 657
Joined: 10-March 07
From: Swindon, Wilts, UK
Member No.: 6



What I would recommend is a switch like the following:

CODE
<?php
switch($_GET['page'])
{
   case 'home':
      echo file_get_contents('home.html');
      break;
   case 'work':
      echo file_get_contents('portfolio.html');
      break;
   default:
      echo file_get_contents('error.html');
}
?>


You add a case for each entry, which means that you can easily make the URL and filename different (as shown in this example ?page=work included portfolio.html), if none of the cases match it does the default which is an error page. It's good for those of us with paranoia as well, because since we explicitly include each page with hardlinks it's not possible to sneak in some user input which would cause us to include a remote page.

References:
http://php.net/switch
http://php.net/include_once
Go to the top of the page 
 
  + Quote Post
Earpy
post Oct 24 2007, 04:51 PM
Post #4


Newbie
*

Group: Members
Posts: 27
Joined: 19-September 07
From: England, United Kingdom
Member No.: 121



Thanks, both of you, for your replies. Your help is much apperciated smile.gif
Go to the top of the page 
 
  + Quote Post
 Reply to this topic Start new topic
left right
0 Members:
left right
 


Lo-Fi Version Time is now: 10th February 2012 - 04:22 AM