[UNCLASSIFIED]RE: [clug] need another set of eyes - PHP when no v ariable is passed

Antti.Roppola at brs.gov.au Antti.Roppola at brs.gov.au
Thu Mar 30 03:24:01 GMT 2006


Try:

If(empty($menu)) {
	$menu="somevalue";
}

BTW, more recent versions of PHP are a lot more strict with
variable scoping and do not accept HTTP _POST and _GET blindly,
Your need to use $_GET['menu'].

Also, what happens if I try http://yourhost/index.php?menu=/etc/passwd ?
I have created something similar to what you describe, but $menu gets fed
through a case statement that ends with a sane default if it doesn't
match anything on my list of allowed values.

Antti
 

-----Original Message-----
From: linux-bounces+antti.roppola=brs.gov.au at lists.samba.org [mailto:linux-bounces+antti.roppola=brs.gov.au at lists.samba.org] On Behalf Of Kristy A. Bennett
Sent: Thursday, 30 March 2006 2:11 PM
To: linux at lists.samba.org
Subject: [clug] need another set of eyes - PHP when no variable is passed

Okay,

It's just one of those days >:o

Okay so here's the dilemma.  I have a page - say index.php which has a variable 'menu' to be passed back to itself.  This variable is then used to call in flash movie (yeah, yeah I know....).  This part was working and but I have since broken it again.  However, the problem does not lie here.

I cannot for the life of me work out how to set a default variable if one is not passed (eg user goes to index.php as opposed to index.php?menu="about").

I have tried if(!$menu) {blah} and if ($menu=="") {blah}.  Neither work
- is there any other solution that I have just simply overlooked?

-- 

KrisB
   *****
Another Linux Hacker Production Unit
http://www.kristy.id.au
        *****

--
linux mailing list
linux at lists.samba.org
https://lists.samba.org/mailman/listinfo/linux

---------------------------------------------------------------------- 
IMPORTANT - This message has been issued by The Department of Agriculture, Fisheries and Forestry (DAFF).  The information transmitted is for the use of the intended recipient only and may contain confidential and/or legally privileged material.  It is your responsibility to check any attachments for viruses and defects before opening or sending them on.  
Any reproduction, publication, communication, re-transmission, disclosure, dissemination or other use of the information contained in this e-mail by persons or entities other than the intended recipient is prohibited.  The taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited.  If you have received this e-mail in error please notify the sender and delete all copies of this transmission together with any attachments.  If you have received this e-mail as part of a valid mailing list and no longer want to receive a message such as this one advise the sender by return e-mail accordingly.  Only e-mail correspondence which includes this footer, has been authorised by DAFF 
----------------------------------------------------------------------


More information about the linux mailing list