<?php
// Database connection
// Connect to MySQL

include_once '../../secure/dbconn.php';



// $conn = mysqli_connect("localhost", "vinkblgn_regportal", "Victor@007", "vinkblgn_regportal");

// Check connection
// if (!$conn) {
//     die("Connection failed: " . mysqli_connect_error());
// }

if (isset($_POST["addtrans"])) {
// Collect form data
$email_address = $_POST['email_address'];
$from = $_POST['from'];
$date = $_POST['date'];
$amount = $_POST['amount'];
$status = $_POST['status'];




// SQL query to update data in the database
$sql = "INSERT INTO transactions (user_email, `from`, date, amount, status)
VALUES ( '$email_address', '$from', '$date', '$amount', '$status')";

if ($conn->query($sql) === TRUE) {
    header("Location:../index.php?added");
    exit();
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}
}
else {
    header("Location:../index.php?error");
    exit();
}



$conn->close();
?>