Re: Need to check whether a param exists!
| From: | 1LT John W. Holmes | Date: | Mon, 03 Feb 2003 17:00:16 +0000 |
| Subject: | Re: Need to check whether a param exists! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-134142@lists.php.net to get a copy of this message | ||
if(isset($_REQUEST['page']))
{ $pagename = $_REQUEST['page']; }
else
{ $pagename = 'home'; }
Should work... If not, let us know. Make sure your case match, too.
?page=hello and ?Page=hello are two different variables.
---John Holmes...
----- Original Message -----
From: "Brian Dunning" <brian@briandunning.com>
To: <php-general@lists.php.net>
Sent: Monday, February 03, 2003 11:54 AM
Subject: [PHP] Need to check whether a param exists!
Hi,
All I'm trying to do is check for the presence of a query string, but
everything I try gives me an Undefined Index error. I want to set a
variable $pagename to whatever was passed as the ?page= value, and if
it wasn't passed, set it to some default value.
http://www.mysite.com/index.php?page=hello
<?php
if (is_object($_REQUEST['page']))
$pagename = $_REQUEST['page'];
else
$pagename = "home";
?>
I also tried is_null, tried if($_REQUEST) by itself, also tried all of
these with $_GET, $_POST, $_GLOBAL, but they all give me Undefined
Index error on that If line.
- Brian
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php