Jump to content

[SOLVED] How to prevent the include content from being called independantly?


stupidav

Recommended Posts

I am putting together a page made up of several pages using PHP, I am pretty new to PHP. My main page is listed below.

 

What I am afraid of is, search engines will only list one of the items that I am "including".

 

I have seen where cookies are used for passwords protected pages, to redirect to a login or other page. Is somthing along those lines, going to be the best way to ensure that if someone tries the www.xxxxxxx.com/body.php that it redirects to www.xxxxxxx.com/index.php, which will assemble the page properly with the ....body.php? The pages are not password protected.

 

If so how do I make the cookie expire, once the page completes loading?

 

I thought that it might be better to at the top of the page set a variable to a specific value, and then at the begining of each of the individual pages, look to see if the variable = specific value, if so continue, of not redirect, and at the end of the last page clear the variable? If this is possible, what would it be called so I can look it up, and learn or are there any examples I can look at?

 

index.php

 

<?php

define('IN_PHP', true);

$php_root_path = './';

include($php_root_path . 'extension.inc');

include($php_root_path . 'root.php'); /*?>for the meta and header part of the page<?php */

include($php_root_path . 'header.php'); /*?>for the header part of the page<?php */

include($php_root_path . 'nav.php'); /*?>for the navigation bar part of the page<?php */

include($php_root_path . 'body.php'); /*?>for the main body and content part of the page<?php */

include($php_root_path . 'footer.php'); /*?>for the footer part of the page<?php */

?>

 

So if I understand this correctly, this would go in the individual pages.

 

if (!defined("IN_PHP"))

 

this is asking if not "IN_PHP" then

 

{header("Location: index.php"); }

 

redirect to "index.php" else if "IN_PHP" then do everything else, correct?

 

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.