$_REQUEST problems in Firefox...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
danjah
Forum Newbie
Posts: 2
Joined: Thu May 14, 2009 11:06 pm

$_REQUEST problems in Firefox...

Post by danjah »

Hi there,

Please don't flame me, I'm a PHP n00b, but not a web n00b, admittedly, I'm also a forum n00b - I've refrained for years and years and years, so consider my posting epic, and very special indeed.

I have an issue, where, in Firefox (3.0.10) my conditional for isset() is always producing a result of 1. In IE8 (lol) it works as I'd expect. Haven't backwards IE tested it yet, because quite frankly it's just becoming a chore when it comes to basic stuff like this, so I'm throwing it at those of you with spare time instead.

Scenario:
$layout = ( isset( $_REQUEST['layout'] ) )? 'alt' : 'flash' ;

When I go to my test url: http://www.codefinger.co.nz/_etc/nu/index.php in FF3, I always see the 'alt' layout and never the 'flash' layout. You'll see in the echo output that $layout is indeed set to 'alt', and isset() is always 1, even with no querystring appended to the url.

When testing in my default install of the latest WAMP, localhost works as I'd expect, 'flash' layout when nothing/invalid is defined, 'alt' when 'alt' is defined. IE8 works the same as localhost does (even though localhost doesn't load in IE since I upgraded, *snicker*).

I'm about to send an email to my host, though deep down I know its my fault somehow. If anyone can correct me, well then thank you in advance. If I hear nout, or I get flamed, then I'll most likely resume my years and years of ignoring the existence of forums.

I've zipped up the current build of my stuff, it's attached (minus the YUI directory; tooltip won't work) - have at it, there should be nothing complex in there.


thanks people,
Danjah
Attachments
Build.zip
(53.04 KiB) Downloaded 3 times
Last edited by Benjamin on Mon May 18, 2009 10:03 am, edited 1 time in total.
Reason: Removed useless poll.
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: $_REQUEST problems in Firefox...

Post by jaoudestudios »

Wont flame you dude! But dont use REQUEST! If it is a GET use a GET, if is a POST then use a POST.

That code is server side, so is not effect by the browser. Try using empty instead of isset.
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: $_REQUEST problems in Firefox...

Post by Darhazer »

Because when you use $_POST, $_ GET and $_COOKIE instead of $_REQUEST, you know exactly where data comes from. And in the case the same variable comes from POST/GET and from COOKIE and you use $_REQUEST, you rely on a server configuration which one you will get, and when you specify if you are reading from $_COOKIE or $_POST/$_GET, you know which one you are reading and you even can compare them.
danjah
Forum Newbie
Posts: 2
Joined: Thu May 14, 2009 11:06 pm

Re: $_REQUEST problems in Firefox...

Post by danjah »

@jaoudestudios & @Darhazer:
Excellent,

I will try empty(), and I will endeavour to not use REQUEST, in favour of the more accurate versions.
And thanks both for not flaming me, perhaps I might even post on a forum in the future!

cheers,
Danj
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: $_REQUEST problems in Firefox...

Post by califdon »

Nobody here is likely to flame you for being a noob, unless they were never one themselves! Some of us occasionally flame someone for inappropriate behavior, but not for being a noob.

Now, the reason I'm writing this is because, as a PHP noob, this will be helpful to you for everything you do in PHP. As jaoudestudios said, PHP is a server side scripting language. The significance of that is that the browser will NEVER SEE any of your PHP code! (At least not unless you REALLY mess up!) All the browser will see is the result of what your PHP code sends to it, which is entirely HTML, CSS, Javascript, etc. If you really understand that, you will avoid many frustrations as you progress along your PHP learning path. Good luck.
Post Reply