Page 1 of 1
PHP ?page= SYSTEM
Posted: Sun Jun 15, 2003 6:29 pm
by sb
Hi!
I want to know how to do CAR.PHP?PAGE=BUS.HTM. I mean like when we type some page address after CAR.PHP?PAGE= it will display that page. I know how to do it in ASP like:
<%
If Request.QueryString("page")="" Then ' if the main.asp?page= is blank it will display the content.asp page below
Server.Execute "content.asp"
Else ' it will load that pageeg page=downloads.asp
Server.Execute Request.QueryString("page")
End If
%>
Please tell me how we do it in PHP. Please.
Thanks.
Posted: Sun Jun 15, 2003 8:02 pm
by Paddy
Code: Select all
<?php
if ($_GET['page'] == "")
header("Location: content.php");
else
{
$url = "Location: ".$_GET['page'];
header($url);
}
?>
Might work.

Posted: Mon Jun 16, 2003 1:48 am
by Judas
another option !
(hybride)
Code: Select all
<?if (isset($cancel_x)){
echo "<script> parent.mainFrame.location=('../../main.php?map=".$map."&alias=".$alias."&event=".$event."');</script>"; ?>
Here is $cancel the name for a image field (!on submit this var wil be renamed to cancel_x and cancel_y )
btw i copy past this from a working model

Posted: Mon Jun 16, 2003 3:16 am
by twigletmac
Judas wrote:another option !
(hybride)
Code: Select all
<?if (isset($cancel_x)){
echo "<script> parent.mainFrame.location=('../../main.php?map=".$map."&alias=".$alias."&event=".$event."');</script>"; ?>
Here is $cancel the name for a image field (!on submit this var wil be renamed to cancel_x and cancel_y )
btw i copy past this from a working model

This code would not work if register_globals was off. register_globals is off by default and deprecated. Judas, please ensure that you have read
Before Post Read: General Posting Guidelines.
It also requires JavaScript on to run (although there's no indication of which language the <script> tags enclose I assume it's JS) and is for use on a site using frames, which doesn't seem to be what the original poster had.
Mac
Posted: Mon Jun 16, 2003 3:21 am
by twigletmac
Another piece of alternative code could be:
Code: Select all
<?php
if (empty($_GET['page'])) {
include 'content.php';
} else {
// make sure that you do some validation of this variable though,
// you don't want people to be able to include their own pages for
// example and use them to find sensitive information on your system.
// You need to check that the page is on your server, not on a remote
// server and that it is not a sensitive file that you wouldn't want
// users to see.
include $_GET['page'].'.php';
}
?>
As I state in the comments, please do some validation on the user input before just including whatever they put in the query string.
Mac