<div class="container">
    <h1>Cancel Transaction</h1><hr>
</div>

<?php
if(isset($_POST["canc_trans"]) && isset($_POST["acc_no"]) && $_POST["acc_no"]!="" && isset($_POST["trans_amt"]) && is_numeric($_POST["trans_amt"]) ) {
    $conn = new mysqli($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']);
    if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);
    if ($conn->query("UPDATE  `".$GLOBALS['arif_ac']."` SET `AA_BAL` = `AA_BAL` - ".$_POST["trans_amt"]." WHERE  `AA_ACNO` = '".$_POST["acc_no"]."'")){
        $AT_USER = "Admin";
        if ($conn->query("INSERT INTO `" . $GLOBALS['arif_tran'] . "` (`AT_ID`, `AT_TIMESTAMP`, `AT_ADMIN`, `AT_ACID`, `AT_AMOUNT`) VALUES (NULL, CURRENT_TIMESTAMP, '" . $AT_USER . "', '" . $_POST["acc_no"] . "', '" . $_POST["trans_amt"] . "')")) {
            echo "<div class='container alert alert-success alert-dismissible fade in'><a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a><p><strong>Transaction cancelled successfully!!</strong></p><p>Account No:  ".$_POST['acc_no']."</p><p>Amount deducted : Rs. ".$_POST['trans_amt']."</p></div>";
        } else {
            echo "<div class='container alert alert-danger alert-dismissible fade in'><a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a><p><strong>Error in Transaction!!</strong></p></div>";
        }
    }
    else {
        echo "Error in Transaction!!";
    }
    $conn->close();
}
?>

<div class="container">
    <form method="post" enctype="multipart/form-data" id="cancelTransaction">
        <input type="hidden" name="canc_trans">
        <div class="form-group">
            <label for="">Enter Account No:</label>
            <input class="form-control" type="text" name="acc_no">
        </div>
        <div class="form-group">
            <label for="">Enter Amount:</label>
            <input class="form-control" type="number" name="trans_amt">
        </div>
        <button type="submit" class="btn btn-success">Submit</button>
    </form>
</div>