
function apex_handle_quote_form(){
    if (!isset($_POST['apex_quote_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['apex_quote_nonce'])), 'apex_quote_submit')) {
        wp_safe_redirect(add_query_arg('quote_status','security',home_url('/contact/'))); exit;
    }
    if (!empty($_POST['website'])) { wp_safe_redirect(home_url('/contact/')); exit; }
    $first = sanitize_text_field(wp_unslash($_POST['first_name'] ?? ''));
    $last = sanitize_text_field(wp_unslash($_POST['last_name'] ?? ''));
    $company = sanitize_text_field(wp_unslash($_POST['company'] ?? ''));
    $email = sanitize_email(wp_unslash($_POST['email'] ?? ''));
    $phone = sanitize_text_field(wp_unslash($_POST['phone'] ?? ''));
    $country = sanitize_text_field(wp_unslash($_POST['country'] ?? ''));
    $product = sanitize_text_field(wp_unslash($_POST['product_interest'] ?? ''));
    $throughput = sanitize_text_field(wp_unslash($_POST['throughput'] ?? ''));
    $message = sanitize_textarea_field(wp_unslash($_POST['message'] ?? ''));
    if ($first === '' || $last === '' || $company === '' || !is_email($email) || $product === '' || $message === '') {
        wp_safe_redirect(add_query_arg('quote_status','invalid',home_url('/contact/'))); exit;
    }
    $subject = sprintf('Website RFQ: %s - %s %s', $company, $first, $last);
    $body = "New request from apexsysprod.com\n\n".
        "Name: $first $last\nCompany: $company\nEmail: $email\nPhone: $phone\nCountry: $country\n".
        "Product Interest: $product\nExpected Throughput: $throughput\n\nProject Details:\n$message\n";
    $headers = array('Reply-To: '.$first.' '.$last.' <'.$email.'>', 'Cc: info@apexsysprod.com');
    $sent = wp_mail('sales@apexsysprod.com', $subject, $body, $headers);
    wp_safe_redirect(add_query_arg('quote_status', $sent ? 'success' : 'mail-error', home_url('/contact/'))); exit;
}
add_action('admin_post_nopriv_apex_quote_submit','apex_handle_quote_form');
add_action('admin_post_apex_quote_submit','apex_handle_quote_form');
?>
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://apexsysprod.com/wp-sitemap.xsl" ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><url><loc>https://apexsysprod.com/author/admin/</loc></url></urlset>
