tags:

views:

134

answers:

4

Hi everyone, ie does not render my php if statement well, any ideas? I say this because it works well in firefox.

<input type="image" src="Images/submit.png" value="REGISTER" name="command" />

    if($_REQUEST['command'] == 'REGISTER'){
        print "test";
    }
    else{

    }

It is not printing "test"

+11  A: 

Internet Explorer is not interpreting your PHP statement at all.

PHP is a server-side programming language, i.e. executed at the server, not the client.

Please rephrase your question. By your previous posts it seems you realize that.

EFraim
It works in firefox though...
Idealflip
@Idealflip please show your generated HTML.
Pekka
Thats not completely true EFraim. Internet Explorer could be sending different information to the server then the other browsers. If you cruise the PHP docs ever you'll know there are work arounds for IE and for Windows for various PHP stuff. PHP, and $_REQUEST, are taking information FROM the browser i.e. "client side". EFraim, i'd assume even the most n00b PHP developer would know that... So, let's try not to be an ass, EFraim.
Oscar Godson
@Oscar: I know explorer *sends* different information. However the point is explorer does not render the *if* statement. It renders its result. (That is, unless the server is misconfigured and outputs PHP unparsed) As for being an ass read my whole answer. Otherwise you *might* be one
EFraim
@Oscar I have to agree with @EFraim here, if there is a difference between browsers, then it is a difference in rendering broken (PHP source) code and not really relevant. It would be really, really helpful to see the *actually generated HTML code*.
Pekka
@pekka He did say the rendered code, a few times. He said that in browsers except firefox it says test, in IE it doesnt say it. Thats all the code he had.@EFraim i know literally IE doesn't change the PHP code, but you knew what he meant, and apparently mmattax who fixed his problem figured it out too. It's the same as in forums or comments when some one uses "their" instead of "they're" and get's flamed for it and doesnt get an answer, but get numerous replies. Im just saying c'mon, do you have to be such a smart ass?
Oscar Godson
@Oscar: No I didn't know what he meant. He would not be the first PHP programmer I meet who does not know the difference between the client-side and server-side. Therefor your comment is not helpful and outright rude.
EFraim
+2  A: 

PHP is executed server side; IE has no bearing on your if statement. My guess is that $_REQUEST['command'] is not being set.

What does this print:

if(empty($_REQUEST['command')) print 'command is empty';

Another idea would be to append the "command" data to your URL:

http://localhost/your-php-script.php?command=foo

EDIT Just noticed that you're using type="image", I don't know if IE supports that: http://www.codingforums.com/archive/index.php/t-79035.html, try using a regular submit button.

mmattax
It prints command is emptymy code works well in firefox, that's why I'm saying it doesn't work in internet explorer
Idealflip
@Ideaflip what happens when you append the command data in the querystring? Your if statement is probably working, the $_REQUEST var is not being set.
mmattax
@Ideaflip Looks like IE doesn't pass data with the <inpu type="image" ... >, change it to a regular submit button.
mmattax
Is every PHP developer retarded? $_REQUEST is getting information FROM THE BROWSER. My god, why do you think you can get the browser information with PHP? I'm sorry idealflip, youd think someone would know that.
Oscar Godson
mmattax was correct! IE was not rendering the type="image", once I changed it back, everything was perfect!
Idealflip
+4  A: 

You're missing the <?php ... ?> tags surrounding your PHP code.

Dan Breen
A: 

However: You should check first, if $_REQUEST['command']; is set

if(isset($_REQUEST['command'])) {
    if($_REQUEST['command'] == 'REGISTER'){
        print "test";
    }
    else{

    }
}
unset