<?php

require 'connect.php';

if(isset($_POST['delete']))
{
    
    // $conn = mysqli_connect("localhost", "akfinanc_admin", "boy510251023Aa", "akfinanc_ascension") or die("Could not connect to mysql".mysqli_error($conn));
    
    $id = $_POST['trans_id'];
    
    $query = "DELETE FROM transactions WHERE id='$id' ";
    $query_run = mysqli_query($conn, $query);

    if($query_run)
    {
        echo '<script>window.location.replace("index.php");</script>';
    }
    else
    {
        echo '<script>window.location.replace("error.php");</script>';
    }    
}


// DELETE ADMIN DATA
// if(isset($_POST['delete']))
// {
//     $id = $_POST['trans_id'];
//     $conn = mysqli_connect("localhost", "springwe_useradmin", "supportadmin", "springwe_in") or die("Could not connect to mysql".mysqli_error($connect));
//     $query = "DELETE FROM transactions WHERE id='$id' ";
//     $query_run = mysqli_query($conn, $query);

//     if($query_run)
//     {
//         $_SESSION['status'] = "Your Data is Deleted";
//         $_SESSION['status_code'] = "success";
//         header('Location: transactions.php'); 
//     }
//     else
//     {
//         $_SESSION['status'] = "Your Data is NOT DELETED";       
//         $_SESSION['status_code'] = "error";
//         header('Location: transactions.php'); 
//     }    
// }




// if(isset($_POST['del'])) {
//  $id = $_POST('trans_id');
 
//  $conn = mysqli_connect("localhost", "springwe_useradmin", "supportadmin", "springwe_in") or die("Could not connect to mysql".mysqli_error($connect));
//   date_default_timezone_set('Africa/Lagos');
//  $sql = mysqli_query($conn, "DELETE FROM transactions WHERE ID = $id");
 
//  if($sql) {
//      echo 'Done';
//  }
// }

?>

