Jump to content

[SOLVED] Help Setting Up Dynamic Content With PHP


bicho83

Recommended Posts

Ok, I am gonna try explaining my problem once again:

 

You guys have seem websites where the URL has something like: somewebsite.com/?pageid=whatever    right?

 

Well I want to set up a website like that (because I don't want to rewrite the whole structure of the website in each and every content page). I don't know how to do that, but I know I am getting closer each time, and any help would be greatly appreciated.

 

My Content pages are stored in a /content folder inside the root. My links are set up like this (for example):

./?page=privacy_policy

 

I know I have to mess around with my index.php and declare some function. Every time somebody replies with some gibberish code that doesn't work (they assume things that I don't know). I have little knowledge of PHP.

here is a good way of doing it, like suggested above.

 

you create your layout so it is coded but leave the content blank.

then in that area place this code:

 

$ext = ".php"; //the file extensions.

if(!isset($_GET['page'])){
$page = "news";
}else{
$page = $_GET['page'];
}

$page = "content/".$page.$ext;

if(!file_exists($page)){
echo "The requested page could not be found.";
}else{
include($page);
}

 

then to access your links you would go:

www.site.com/index.php?page=privacy_policy

 

or

 

www.site.com/?page=privacy_policy

 

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.