PHP ?page= SYSTEM

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sb
Forum Newbie
Posts: 3
Joined: Sat Jun 14, 2003 1:30 pm

PHP ?page= SYSTEM

Post 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.
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post by Paddy »

Code: Select all

<?php
if ($_GET['page'] == "")
      header("Location: content.php");
else
{
      $url = "Location: ".$_GET['page'];
      header($url);
}


?>
Might work. :)
Judas
Forum Commoner
Posts: 67
Joined: Tue Jun 10, 2003 3:34 pm
Location: Netherlands

Post 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 :)
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Post Reply