I want to know how can I have pages like http://www.domain.com/page.php?type=2 .
<?
if ($page) {
include "path/to/your/content/$page";
}
else { include "path/to/default/content"; }
?>
1) Can the content be *.shtml?Originally posted by bigperm
Create a template. No content. Make pages with your content and name them however you want to name them, by numbers or by name.
Then in your template where you want your content have:
PHP:<? if ($page) { include "path/to/your/content/$page"; } else { include "path/to/default/content"; } ?>
1) No. Not unless you modified your htaccess to parse shtml pages as php for some reason. PHP pages should be named *.php to be parsed.Originally posted by The Red Guy
1) Can the content be *.shtml?
2) What does else { include "path/to/default/content"; }
do?
<?
if ($page) {
include "path/to/your/content/$page";
}
else { include "path/to/default/content"; }
?>
1) That is php include.Originally posted by The Red Guy
1) Then can I use php include instead?PHP:<? if ($page) { include "path/to/your/content/$page"; } else { include "path/to/default/content"; } ?>
2) path/to/your/content/$page - Must I replace the $page with my .php page?
3) Do you know where I can find this tutorial?
1)How do I link to that particular page?Originally posted by bigperm
1) That is php include.
2)No. $page is a variable that is defined when you access the page like you said in your first post... index.php?page=whatever.ext
3)http://php.net
1)Which page are you talking about?Originally posted by The Red Guy
1)How do I link to that particular page?
2) Do you have that specific link to that tutorial? I've tried to find it at php.net but to no avail.
If that's an issue, but store your content files below your httpdocs (or whatever) folder, use .htaccess to prevent unwanted lookers or you can use a DB. There's still no reason to hard code them.Originally posted by AlieXai
> But why hard code the file names if you don't have to?
Security
1) Can I make the john.php as the front page instead of the john.php?page=2 ?Originally posted by Moonman
OK, say you have a file called john.php, and in that file you have
<?
if ($page == "2") {
include("yourfile.php");
} elseif ($page == "3") {
include("anotherfile.php");
}
?>
then when you go to www.test.com/john.php?page=2
it will show yourfile.php, but say you go to www.test.com/john.php?page=3
then it will show anotherfile.php
to change the john.php?page= bit you must edit
if ($page == "2") and change the page bit. like say you change the script above to
<?
if ($fred == "2") {
include("yourfile.php");
} elseif ($fred == "3") //notice i also changed the page bit here
{
include("anotherfile.php");
}
?>
and saved that file called john.php
then you went to www.test.com/john.php?fred=2
then it would show yourfile.php
but another bit of the code you can change is
if ($fred == "2")
like you can change that to
<?
if ($fred == "page2") {
include("yourfile.php");
} elseif ($fred == "page3") {
include("anotherfile.php");
}
?>
and again save that as john.php
when you go to www.test.com/john.php?fred=page2
it will go to yourfile.php,
but if you go to www.test.com/john.php?fred=page3
it will go to anotherfile.php
Understand? if not i will find a good tutorial to explain all this.