<?php
// Test the contact form submission directly
require_once 'index.php';

$CI =& get_instance();
$CI->load->model('inquiry_model');

// Simulate form submission
$test_data = array(
    'type' => 'contact',
    'name' => 'Test User',
    'email' => 'test@example.com',
    'phone' => '1234567890',
    'subject' => 'Test Subject',
    'message' => 'This is a test message from the debug script.',
    'status' => 'new',
    'ip_address' => '127.0.0.1',
    'created_at' => date('Y-m-d H:i:s')
);

$id = $CI->inquiry_model->insert($test_data);

if ($id) {
    echo "✓ SUCCESS! Test inquiry inserted with ID: " . $id . "\n";
    
    // Verify it was inserted
    $result = $CI->inquiry_model->get($id);
    if ($result) {
        echo "✓ Verified: Inquiry exists in database\n";
        echo "Name: " . $result['name'] . "\n";
        echo "Email: " . $result['email'] . "\n";
    }
} else {
    echo "✗ FAILED: Could not insert test inquiry\n";
}

// Check last error
echo "\nLast DB error: \n";
print_r($CI->db->error());