Jump to content

[SOLVED] $_REQUEST


unidox

Recommended Posts

I have this code:

 

<?
	if ($_REQUEST['p']){
	include("incs/files.inc.php");
	} else {
	echo "We are still in developement";
	}

 

Now as of now, if someone types in index.php?p=asd

 

It will not find it, and it will go blank, is there a way I can set a default so if someone does go to asd, it shows the default page?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/73727-solved-_request/
Share on other sites

That wouldnt work, cause in mt files.inc.php I have this:

 

$request = $_REQUEST['p'];
include("incs/conf.inc.php");

/***************************************************************
******************* START HOME *********************************
****************************************************************/
if($request == "admin_home") {

Link to comment
https://forums.phpfreaks.com/topic/73727-solved-_request/#findComment-372009
Share on other sites

<?
	if ($_REQUEST['p']){
	include("incs/files.inc.php");
	} else {
	echo "We are still in developement";
	}

 

Change this to:

 

<?php

$request = $_GET['p'];//safer using $_GET rather than $_REQUEST
include("incs/files.inc.php");
} else {
echo "We are still in development.";
}
?>

 

In files.inc.php, remove that first line and change the conditionals:

$request = $_REQUEST['p'];
include("incs/conf.inc.php");

/***************************************************************
******************* START HOME *********************************
****************************************************************/
if($request == "admin_home") {

 

So you have:

 

include("incs/conf.inc.php");

/***************************************************************
******************* START HOME *********************************
****************************************************************/
switch($request){
case 'admin_home'
//do something
break;
default 
//do something if it doesn't match
break;
}

 

 

The reason being is that once you define a variable initially on one page, and include a php file, that variable will be passed through the file so you don't need to redefine it.

Link to comment
https://forums.phpfreaks.com/topic/73727-solved-_request/#findComment-372012
Share on other sites

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.