Kinetic Pulse
  • Home
  • Services
  • Portfolio
  • Blog
  • Terms
  • Contact

$_POST Variables for Image input buttons

April 14, 2010

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:

if($_POST['btnSubscribe']!=""){
//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

Share

Facebook Google+ Twitter Pinterest Email

Back to Blog

Testimonials

Thanks so much for all your work on this, really appreciated. It’s come on in leaps and bounds since you took over.
Pete KewRedwood Strip Curtains
Thank you for all of your hard work its looks fab and I am over the moon with it!
Amanda MercerAmanda Mercer Ceramics
It’s been fab working with you – we love the site and certainly going to recommend you!
James DaviesThirty Eight Degrees North
Amazing and brilliant, Kinetic Pulse have lifted a dream to reality, Highly recommended and great if you are total novice, they know their stuff…Thanks again
Annie LindridgeSalt Yourself Out
Thank you guys so much for all that you’ve done helping us to create a really awesome website!! We get such great feedback – everyone loves it & we couldn’t be prouder! Look forward to working with you again soon!
Wild Thyme PlantsWild Thyme Plants
Absolutely fantastically professional web developer – I would highly recommend!!! Thank you so much Kinetic Pulse!
Tania MarstonDoris Designs
I like it.  I like it a lot !!!

 You have interpreted what I wanted to achieve perfectly considering what you have to play with i.e not redoing the whole thing in the process.

Fiona Simmons-MooreSouth Gloucestershire Parents & Carers

Twitter

@HMRCcustomers Will do - thanks for the swift response

Last year from Kinetic Pulse's Twitter

@HMRCcustomers I've submitted Self Assessment repayment requests multiple times over the past 6 months (always waiting 4 weeks between) and never has anything happened. There seems to be no way of tracking or chasing them either. Now, of all times, this is important

Last year from Kinetic Pulse's Twitter

Apologies to all clients who have had website issues today. There was a major outage for our hosting company @cloudabove but, as always, they have been fantastically open and transparent about what's going on and are working hard to restore service.

About a year ago from Kinetic Pulse's Twitter

@thegrapesbath @bathdrummer Thanks - looking forward to opening night!

About 2 years ago from Kinetic Pulse's Twitter

woobox.com/tjkbms/k1orue

About 3 years ago from Kinetic Pulse's Twitter

Copyright 2021 Kinetic Pulse