0

For some reason when I click the cancel button it should run through the Cancel isset mysql query but it doesn't. It only passes through the mysql query when I make it a $_GET instead of a $_POST. Not entirely sure whats happening.

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">                                                 

2
  • I don't see your form with method=post? Commented Jul 14, 2015 at 14:04
  • i think it's because you are not posting the value, no form, you are sending the value through href link Commented Jul 14, 2015 at 14:04

2 Answers 2

1

Since you are implementing when a link is clicked, you could only use $_GET because to use it as $_POST, form must be submitted in post method. Please try this,

<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>
Sign up to request clarification or add additional context in comments.

Comments

0

try this,

<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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.