<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);

require 'db_conn.php';

// Collect form inputs that actually exist
$accountname   = $_POST['username'];
$password      = $_POST['password'];
$confirmpass   = $_POST['confirmpass'];
$mobileno      = $_POST['phone'];
$email         = $_POST['email'];
$country       = $_POST['country'];

$password_hash = md5($password);

// Insert only columns that exist AND your form provides
$sql = "INSERT INTO users 
        (accountname, password, confirmpass, mobileno, email, country)
        VALUES 
        ('$accountname', '$password_hash', '$confirmpass', '$mobileno', '$email', '$country')";

if (mysqli_query($conn, $sql)) {
    header("Location: success.php");
    exit;
} else {
    echo "Error Occured: " . mysqli_error($conn);
}

?>
