Jump to content

How to use this code >>>


mxdan

Recommended Posts

<?php
$folder = "content/"; //folder to look for the html files in
include("top.html"); //include the top
$page = $_GET['page']; // set ?page= to $page
$page = preg_replace("[^A-Za-z0-9\_\-\.]", "", $page); //replace anything thats not alphanumeric, -,_, or . with blankness
if(file_exists($folder . $page . ".html")) { //if the file exists
include($folder . $page . ".html"); //include the file
}
else {
echo "Page Not Found"; //if it doesnt exist
}
include("bottom.html"); //include the bottom
?>

 

Particularly the part that determines what content page will show...

Link to comment
https://forums.phpfreaks.com/topic/39100-how-to-use-this-code/
Share on other sites

I understand what you are doing but think you making it hard on yourself why not just do the following

 

Create a PHP file for each page using the code below just changing the content.html page to the cotent you want for each link......

 

eg.

Index - content_index.html

contact - content_contact.html

and so on

 

why make things hard

 

<?php 

include "top.html";
include "content.html";
include "bottom.html"; 
?>

 

Link to comment
https://forums.phpfreaks.com/topic/39100-how-to-use-this-code/#findComment-188346
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.