简体   繁体   中英

PHP SQL UPDATE works in FF and CHROME but not in IE?

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

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.

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.

另一种方法是检查$_POST[{image-element-name}_x}] (在本例中$_POST['updatebucket_x'] 。所有浏览器都将图像元素的x / y坐标作为updatebucket.xupdatebucket.y ,和PHP默默的(和令人沮丧的)改变updatebucket.xupdatebucket_x 。再说,你只需要这一下不同的输入类型=提交/类型=图像元素会改变所采取的行动,否则的以前的解决方案如先前建议的隐藏元素可以。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM