tags:

views:

61

answers:

3

Hi, the below code works perfectly in FF and CHROME but not in IE. Please help. I have commented out my santize functions as i thought they might be affecting it, but it still does the same.... nothing in IE. Thank you in advance for any assistance.

<?php 

//IF UPDATE BUCKET CHANGE STATUS...
if(isset($_POST['updatebucket'])){


 $complete = $_POST["complete"];
 $bucketid = $_POST["bucketid"];

//$complete = sanitizeone($_POST["complete"], "plain");
//$complete = strip_word_html($complete);
//$bucketid = sanitizeone($_POST["bucketid"], "plain");
//$bucketid = strip_word_html($bucketid);

if ($complete=="1")
  $complete = "0";
else
  $complete = "1";

$updatebucket = "UPDATE membersbuckets SET complete = '$complete' WHERE userid = '$userid' AND bucketid = '$bucketid'"; 
mysql_query($updatebucket);
}
?>

and the front end....

<? if ($complete=="1") {
    echo "<form action='' method='post' name='updatebucket'><input name='complete' type='hidden' value=" .$complete. " /><input name='userid' type='hidden' value=" .$userid. " /><input name='bucketid' type='hidden' value=" .$bucketid. " /><input type='image' name='updatebucket' value='updatebucket' src='images/tick.png' /></form>";
    }else{
    echo "<form action='' method='post' name='updatebucket'><input name='complete' type='hidden' value=" .$complete. " /><input name='userid' type='hidden' value=" .$userid. " /><input name='bucketid' type='hidden' value=" .$bucketid. " /><input type='image' name='updatebucket' value='updatebucket' src='images/cross.png' /></form>";  
}
?>

Dan

+2  A: 

You should post your front-end, not back-end (since it's pretty much not browser-dependant).

Your HTML probably isn't valid.

Edit:

Yep, IE doesn't take value for image type of input. It only sends the x & y (field_name_x, field_name_y) and totally discards the original "value" attribute.

Try with a hidden input instead.

Kemo
thanks, posted.
Dan
So put the name='updatebucket' value='updatebucket' in another hidden input and just have the image as the "submit" ? or do i have to get rid of the image as the submit button all together?Thanks.
Dan
just add a hidden field, keep the image but for submit only :)
Kemo
Thanks Kemo. Just what i needed!
Dan
A: 

It seems that input type='image' doesn't send the value when used from IE. You'll need another hidden field:

<input type='hidden' name='updatebucket' value='updatebucket' />
<input type='image' src='images/tick.png' />

That way, the updatebucket parameter will be posted to the server, regardless of the browser used.

The assumption here was that all browsers handle HTML forms the same way (and they don't); that's why I keep Eric Lawrence's excellent Fiddler around - it can diff two HTTP requests, so you'll see the difference between the browsers immediately.

Piskvor
Thanks Piskvor. Thats excellent!! :)
Dan
A: 

An alternative would be to check for $_POST[{image-element-name}_x}] (in this case $_POST['updatebucket_x']. All browsers will send the x/y coordinates of the image element as updatebucket.x & updatebucket.y, and PHP silently (and frustratingly) alters the updatebucket.x to updatebucket_x. Then again, you only need this is clicking different input type=submit / type=image elements would alter the action taken, otherwise the previous solution of a hidden element as previously suggested would do.

Wrikken