/    Sign up×
Community /Pin to ProfileBookmark

IE ignores if-clause

Hello,

It seems that IE ignores the PHP-code I put between:

[code=php]if(isset($_POST[‘submit’])) {

// IE ignores this part

}[/code]

and I’ve got no idea what is going on.

Other browsers (FF, Safari, …) are working fine.

Anybody? Thanks a lot.

to post a comment
PHP

13 Comments(s)

Copy linkTweet thisAlerts:
@SyCoJun 17.2008 — it's not an IE thing at this point THis is preocessed before it goes to the browser. PHP is serverside. Might be how you're setting the value of submit in the form, without seeing more theres no way of knowing.

If you have access to the ini file turn up error handling to E_ALL and you'll probably get an undefined error for the missing value. You can do it per script (or in an included header too)

error_reporting()

E_ALL make development much easier once you get used to the extra error messages and if you move your code to a server with E_ALL set you'll be fine. Most peoples code would blow up when moved from a non E_ALL environment.
Copy linkTweet thisAlerts:
@Nicholas222authorJun 17.2008 — Hi SyCo,

The error_reporting is set to E_ALL & ~E_NOTICE.

I thought it couldn't be the apache server because other browsers are doing it correctly.

The submit is being transferred as following:

[code=html]<input type="image" name="submit" src="_img/buttons/submit.gif" value="Send" alt="Send" title="Send" />[/code]

I just don't get it...

Thx
Copy linkTweet thisAlerts:
@SyCoJun 17.2008 — (Edit: isset() prevents the error, If you echo the var direct you'll get an error which can be supressed with an @. isset is the correct thing to use, just adding to the thread for info...)

I just tried print_r($_POST) with the input type image

[code=php]<?
print_r($_POST)
?>
<form method="post">
<input type="image" name="submit" src="http://www.webdeveloper.com/forum/images/webdev-logo2.gif" value="Send" alt="Send" title="Send" />
</form>[/code]

a click gives this
[code=php]Array ( [submit_x] => 54 [submit_y] => 12 ) [/code]
and another click gives
[code=php]Array ( [submit_x] => 21 [submit_y] => 9 ) [/code]
It looks like you have the x and y co-ordinates of the mouse click position and the _X or _y so your test for submit is going to fail.
Copy linkTweet thisAlerts:
@Nicholas222authorJun 17.2008 — but the php-code is actually on another page so the form must be submitted. Otherwise you can't go to the "action"-page, right?

I don't see why there is a difference between IE and other browsers if PHP is processed on the apache server.
Copy linkTweet thisAlerts:
@SyCoJun 17.2008 — Yea this is just an example. I didn't set an action so it goes to itself by default. Set the action in yours and add a hidden input and test for that on the receiving page.
Copy linkTweet thisAlerts:
@Nicholas222authorJun 17.2008 — Array ( [name] => [organisation] => [phone] => [email] => [message] => [submit_x] => 67 [submit_y] => 15 )

(As you can see, I submitted the form without entering information or any validation)

You're right about the mouse coordinates, but how can I fix this for IE?
Copy linkTweet thisAlerts:
@Nicholas222authorJun 17.2008 — FF also passes the coordinates but also the submit-value:

[submit_x] => 28 [submit_y] => 12 [submit] => Send

while IE refuses the last one, so it's a bug? ?
Copy linkTweet thisAlerts:
@Nicholas222authorJun 17.2008 — Ok I found a solution on http://www.webmasterworld.com/forum88/4894.htm

but it shouldn't be this way...

Damned Microsoft! :mad:
Copy linkTweet thisAlerts:
@MrCoderJun 18.2008 — [code=php]
<?php
if(isset($_POST["action"]))
{
switch($_POST["action"])
{
case "send" :
// Do PHP jazz
break;
default :
// Unhandled action
}
}
?>
<form method="post">
<input type="image" name="submit" src="http://www.webdeveloper.com/forum/images/webdev-logo2.gif" value="Send" alt="Send" title="Send" />
<input type="hidden" name="action" value="send">
</form>
[/code]
Copy linkTweet thisAlerts:
@chazzyJun 18.2008 — actually it definitely should be, and provides you a lot of flexibility doing it this way. Let's say you have an image that's something like

[SIZE="7"][COLOR="Lime"]YES [/COLOR][COLOR="Red"]NO[/COLOR][/SIZE]

You can use this extra data in the submit_x and submit_y to find out if they pressed on YES or NO.
Copy linkTweet thisAlerts:
@Nicholas222authorJun 18.2008 — First of all, i would be using 2 imgs, en btw the mouse coordinates are always send, which I don't have a problem with. FF, Safari, ... they all send'em.

The problem is that IE doesn't send the name-attribute and better browsers do.

MrCoder, true but in my opinion, an extra hidden field isn't necessarily needed, as I can also check if the message (for example) was set?

I guess the best solution is :

[code=php]if(isset($_POST['submit']) || isset($_POST['submit_x'])) {

// do this

}[/code]
Copy linkTweet thisAlerts:
@MrCoderJun 18.2008 — MrCoder, true but in my opinion, an extra hidden field isn't necessarily needed, as I can also check if the message (for example) was set?[/QUOTE]

I just like my method since you can handle multiply actions from one switch/case (Or if/else if that's your thing) using the hidden value.
Copy linkTweet thisAlerts:
@Nicholas222authorJun 18.2008 — That's true, no offence ? but not really the essence of the thread...

( I know, the subject might be a bit confusing...)

Thanks anyway for thinking with us!!
×

Success!

Help @Nicholas222 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...