mxdan Posted February 19, 2007 Share Posted February 19, 2007 <?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 More sharing options...
Wildhalf Posted February 19, 2007 Share Posted February 19, 2007 What are you trying to do?? Link to comment https://forums.phpfreaks.com/topic/39100-how-to-use-this-code/#findComment-188293 Share on other sites More sharing options...
mxdan Posted February 19, 2007 Author Share Posted February 19, 2007 To make it so I have a top.html and bottom.html. Which makes my layout and in between my content pages go. Link to comment https://forums.phpfreaks.com/topic/39100-how-to-use-this-code/#findComment-188302 Share on other sites More sharing options...
Wildhalf Posted February 19, 2007 Share Posted February 19, 2007 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 More sharing options...
marcus Posted February 19, 2007 Share Posted February 19, 2007 Why not check if your page is alphanumeric instead of replacing it. if(!ctype_alnum($page)){ include('index.html'); }else { if(file_exists($page)){ include("whatever"); }else { include('index.html'); } } Link to comment https://forums.phpfreaks.com/topic/39100-how-to-use-this-code/#findComment-188353 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.