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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.