I’ve just run up against something weird.
My PHP code which was detecting which of two buttons a user had clicked on a form had suddenly stopped working. Or to be exact, had stopped working in Internet Explorer.
I was using the $_POST variable of the button name to detect if it had been clicked.
For example the two buttons were called “Register” and “Subscribe” – so if I wanted to see if the Subscribe button had been clicked I would perform the following check in the submit process:
//echo "add subscription to basket;
where ‘btnSubscribe’ was the name of the input
Which all worked fine until I changed the input type form a button to an image.
Now I get these extra $_POST variables:
$_POST[‘btnSubscribe_x’] and $_POST[‘btnSubscribe_y’] and most weird of all I only get the $_POST[‘btnSubscribe’] variable in Firefox (and I’m guessing in other “normal” browsers like Safari, Chrome etc)
But in Microsoft’s odd ball of a browser, Interent Explorer 7 and 8, it is no longer there!!
Which is what was breaking my code! And it took me ages to track down, so I’m sharing it with you. I’ve now changed my submit code to detect the presence of $_POST[‘btnSubscribe_x’].
Lesson learnt: Use images for buttons from Day 1 so you know to code round their quirks – rather than leave it till the 11th hour