|
help please,
I am a newbie to php, although im not new to programming and can work out most things. Either I cant see the what maybe staring me in the face or im missing something.
Im trying to get variables from an url, and thats fine like this:
$cpage=$_REQUEST['cpage'];
$l1page = $_REQUEST['l1page'];
$l2page = $_REQUEST['l2page'];
for an url like this:
localhost/index.php?cpage=ViewNews.php&l1page=LeftMenu.php&l 2page=LeftMenu2.php&npage=1
but if the url has no info in it like
localhost/index.php
then im getting lots of these warnings
Notice: Undefined index: npage in C:\wamp\www\ViewNews.php on line 14
I want to know how to check if the data in the url exists, and fix the code
I know i can turn off these warnings, but i'd rather fix the code.
nb, i have tried this:
if (empty($cpage))
{
$cpage='ViewNews.php';
}
but it doesn't seem to work, what i want it to do is if the page is the base web url or localhost, redirect to the page above, else read what variables are there and direct to that page.
My problem is that every link needs to be treated like this as my index page is set to load a header, menus and the main page as includes so i really need to get this working correctly
*update
I tried this:
global $cpage;
$cpage='';
if (!isset($cpage))
{
$cpage=$_REQUEST['cpage'];
}
if (empty($cpage))
{
$cpage='ViewNews.php';
}
although it fixes the define error, i cant read in the new link variables
Last edited by mickle026; 11-05-2009 at 04:23 AM..
|