出于某种原因,当我单击取消按钮时,它应该通过Cancel isset mysql查询运行,但它没有。当我将它设为$ _GET而不是$ _POST时,它只会通过mysql查询。不完全确定发生了什么。
if(isset($_POST["Cancel"])) {
$sCancel = $dbh->prepare("
UPDATE MaterialOrders
SET `cancelledByUid` = :uid,
`cancelled` = 'true'
WHERE `idMaterialOrders` = :idMaterialOrders
");
$sCancel->bindValue(":uid", $_SESSION["uid"]);
$sCancel->bindValue(":idMaterialOrders", $_GET["oid"]);
if ($sCancel->execute()) {
$sCancel->closeCursor();
}
}
<a href="includes/orderItems.php?Cancel=true&oid=<?php print $_GET['oid']; ?>" class="supplierMaterial" target="_blank">
<input type="button" value="Cancel Order" name="Cancel" id="Cancel">
答案 0 :(得分:1)
由于您在单击链接时实现,因此只能使用$ _GET,因为要将其用作$ _POST,必须使用post方法提交表单。请试试这个,
<a href="includes/orderItems.php?Cancel=true&oid=<?php print $_GET['oid']; ?>" class="supplierMaterial" target="_blank">
<input type="button" value="Cancel Order" name="Cancel" id="Cancel">
</a>
答案 1 :(得分:0)
试试这个,
<form method="post" action="includes/orderItems.php">
<a href="?Cancel=true&oid=<?php print $_GET['oid']; ?>" class="supplierMaterial" target="_blank">
<input type="button" value="Cancel Order" name="Cancel" id="Cancel">
<input type="submit" value="submit" name="submit" id="submit">
</form>