IE Button Value Fix / Rant

So ive been working on this online ordering system for the bookshop I work in, and its been going along quite well, working out php and sql etc. And ive pretty much got it working perfectly, and then i went and did the dreaded Internet Explorer test… DISASTER.

So i find out that using <button> tags is a big no no, cause IE is stupid and thinks that even though you set a value parmater, it will still pass the innerHTML to your POST data. shocking, I just dont understand how that could even be considered to be resonable adhereance to standards, anyway. So i went researching the <input type=“submit”> tags, and find that with that, you still cant have different data passed to your POST, than what the tag of the button is. So i came up with this little PHP work around so that you can still use <button> tags, have fancy looking buttons with pictures and such inside, and stay sane with your POST/GET data.

So normally your tag would be go along these lines:

<button type="submit" name="order" value="fast">Fast Orders</button>

Instead use this, and mesh your variable name and value into the name, with a delimeter, im going to use =, but you can really use anything.

<button type="submit" name="order=fast">Fast Orders</button>

Then at the top of your php page your passing your form data to put this in.

foreach ($_POST as $keys => $values){	//Search all the post indexes
	if(strpos($keys,"=")){              //Only edit specific post fields
		$vars = explode("=",$keys);     //split the name variable at your delimiter
		$_POST[$vars[0]] = $vars[1];    //set a new post variable to your intended name, and set it to your intended value
		unset($_POST[$keys]);           //unset the temporary post index.
	}
}

So hope that helps you or anyone, and I’m back off to battle the Internet Explorer monster for more errors.

-Phorte