简体   繁体   中英

Delete does not work in only Internet Explorer

So this code works in every browser except Internet Explorer. How can I make it work in IE?

//html code

<form action="postdel.php?id=<?php echo $id; ?>" method="POST" onsubmit="return confirm('Confirm: DELETE <?php echo $productname; ?>?');">

<input type="hidden" value="delete" title='Delete Item'> 
 <button style='height:33px; width:50px'>
      <img src="../css/images/delete_25.png" />
 </button>
</form>

//postdel.php

ob_start();
include("../conn.php");

$stmt = $mysqli->prepare("DELETE FROM specials WHERE id = ?");
$stmt->bind_param('i', $_GET['id']);
$stmt->execute();
$stmt->close();

header('Location: foo.php');

$id is just a random number. I'm assuming the problem is with the JavaScript popup to confirm the delete. Because when you press OK, it accepts, removes the dialog and sits back on the same page. All other browsers, it confirms, and goes to the foo page.

You could try giving the form a name using the name attribute, which is applied to the form:

name="deleteform"

would render the following:

form action="postdel.php?id=<?php echo $id; ?>" method="POST" onsubmit="return confirm('Confirm: DELETE <?php echo $productname; ?>?');" name="deleteform">

anyway, I don't know why this isn't working. I just did this as my solution, hopefully it will help someone else.

I just basically got rid of the form all together and just used the button to execute the delete command.

//html

<button onclick="location.href='postdel.php?id=<?php echo $id; ?>'" style='height:33px; width:50px;'><img src="../css/images/delete_25.png" border="0"/></button>

//php

ob_start();
include("../conn.php");

$stmt = $mysqli->prepare("DELETE FROM specials WHERE id = ?");
$stmt->bind_param('i', $_GET['id']);
$stmt->execute();
$stmt->close();

header('Location: foo.php');

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