RE: [PHP] Strange variable received

From: Date: Thu, 15 May 2003 17:32:07 +0000
Subject: RE: [PHP] Strange variable received
Groups: php.general 
Request: Send a blank email to php-general+get-147742@lists.php.net to get a copy of this message
> -----Original Message----- > From: César Aracena [mailto:lists@icaam.com.ar] > Sent: 15 May 2003 16:48 > > I'm trying to send some variables from a form to another page > (first time > since formatting) and I can't get them. When I pointed the form to > phpinfo.php, I get every variable well, except for the > button's name which > I need for an IF statement. It's an image called > "change_default" and the > variables I receive are: > > _POST[change_default_x] 33 > _POST[change_default_y] 17 According to the HTML spec, when you click an <input type="image" ... > button, what is transmitted are the x and y co-ordinates within the button of where you clicked; these are sent as button_name.x and button_name.y. However, as "." is not a valid character in PHP variable names, PHP automagically converts it to "_" when populating your $_POST array. > > so these are the width and height of my button's image, but I So these are not the height and width of your button, but where you clicked within it. > want to get > the button's name as a variable... why is this? You can't get the button's name because it's not transmitted -- you will always get the _X and _y variables as noted above. Just test for the presence of one of these to find out if the button was clicked. (BTW, this is documented in the PHP manual at http://www.php.net/manual/en/language.variables.external.php#language.variab les.external.form.submit) Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: m.ford@lmu.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#147742) next »