<?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["add"])) {
// Collect form data
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$middle_name = $_POST['middle_name'];
$username = $_POST['username'];
$email_address = $_POST['email_address'];
$password = $_POST['password'];
$phone_number = $_POST['phone_number'];
$total_deposit = $_POST['total_deposit'];
$profit = $_POST['profit'];
$running_trade = $_POST['running_trade'];
$bonus = $_POST['bonus'];
$profit_percentage = $_POST['profit_percentage'];
$last_deposit = $_POST['last_deposit'];
$last_withdrawal = $_POST['last_withdrawal'];
$status = $_POST['status'];
$address = $_POST['address'];




// SQL query to update data in the database
$sql = "INSERT INTO users (first_name, last_name, middle_name, username, email_address, password, phone_number, total_deposit, profit, running_trade, bonus, profit_percentage, last_deposit, last_withdrawal, status, address)
VALUES ( '$first_name', '$last_name', '$middle_name', '$username', '$email_address', '$password', '$phone_number', '$total_deposit', '$profit', '$running_trade', '$bonus', '$profit_percentage', '$last_deposit', '$last_withdrawal', '$status','$address')";

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();
?>