0, 'time' => time()]; } $data = $_SESSION[$key]; if (time() - $data['time'] > 3600) { $_SESSION[$key] = ['count' => 0, 'time' => time()]; $data = $_SESSION[$key]; } if ($data['count'] >= 3) { return false; } return true; } // Input validation function validateInput($data, $type = 'text') { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data, ENT_QUOTES, 'UTF-8'); switch ($type) { case 'email': return filter_var($data, FILTER_VALIDATE_EMAIL) ? $data : false; case 'phone': return preg_match('/^[\+]?[0-9\s\-\(\)]+$/', $data) ? $data : false; case 'text': return strlen($data) > 0 ? $data : false; case 'long_text': return strlen($data) >= 20 ? $data : false; default: return $data; } } // Check if request is AJAX function isAjaxRequest() { return !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'; } // Response function function sendResponse($success, $message, $data = null) { // If AJAX request, send JSON if (isAjaxRequest()) { $response = [ 'success' => $success, 'message' => $message ]; if ($data !== null) { $response['data'] = $data; } header('Content-Type: application/json'); echo json_encode($response); exit; } // Otherwise, display HTML response page displayHTMLResponse($success, $message); } // Display HTML response page function displayHTMLResponse($success, $message) { $pageTitle = $success ? 'Quote Request Sent Successfully' : 'Quote Submission Error'; $messageClass = $success ? 'success' : 'error'; ?> <?php echo htmlspecialchars($pageTitle); ?> - UK Data Services

'; foreach ($errors as $error) { if (trim($error)) { echo '
  • ' . htmlspecialchars(trim($error)) . '
  • '; } } echo ''; } else { echo htmlspecialchars($message); } } ?>
    Return to Home Read Our Blog Return to Home

    We'll be in touch within 24 hours with a detailed proposal.

    Have questions? Email us at info@ukdataservices.co.uk

    If you continue to experience issues, please contact us directly:

    Email: info@ukdataservices.co.uk

    Phone: +44 1692 689150

    'Web Scraping & Data Extraction', 'business-intelligence' => 'Business Intelligence & Analytics', 'data-processing' => 'Data Processing & Cleaning', 'automation' => 'Automation & APIs', 'consulting' => 'Custom Development', 'other' => 'Other Services' ]; $selected_services = array_map(function($service) use ($service_names) { return $service_names[$service] ?? $service; }, $services); // Create friendly scale names $scale_names = [ 'small' => 'Small Project (One-time extraction, < 10k records)', 'medium' => 'Medium Project (Regular updates, 10k-100k records)', 'large' => 'Large Project (Ongoing service, 100k+ records)', 'enterprise' => 'Enterprise (Complex multi-source solution)' ]; $friendly_scale = $scale_names[$project_scale] ?? $project_scale; // Create friendly timeline names $timeline_names = [ 'asap' => 'ASAP (Rush job)', '1-week' => 'Within 1 week', '2-4-weeks' => '2-4 weeks', 'flexible' => 'Flexible timeline' ]; $friendly_timeline = $timeline_names[$timeline] ?? $timeline; // Prepare email content $to = 'info@ukdataservices.co.uk'; $subject = 'New Quote Request - UK Data Services'; // Create detailed HTML email $emailHTML = ' New Quote Request

    🚀 New Quote Request

    UK Data Services

    Received: ' . date('Y-m-d H:i:s') . ' UTC

    👤 Contact Information
    Name:
    ' . htmlspecialchars($name) . '
    Email:
    ' . htmlspecialchars($email) . '
    Company:
    ' . htmlspecialchars($company ?: 'Not provided') . '
    Phone:
    ' . htmlspecialchars($phone ?: 'Not provided') . '
    🎯 Services Required
      '; foreach ($selected_services as $service) { $emailHTML .= '
    • ✓ ' . htmlspecialchars($service) . '
    • '; } $emailHTML .= '
    📊 Project Details
    Project Scale:
    ' . htmlspecialchars($friendly_scale) . '
    Timeline:
    ' . htmlspecialchars($friendly_timeline) . '
    Budget Range:
    ' . htmlspecialchars($budget ?: 'Not specified') . '
    🌐 Data Sources
    ' . nl2br(htmlspecialchars($data_sources ?: 'Not specified')) . '
    📝 Detailed Requirements
    ' . nl2br(htmlspecialchars($requirements)) . '
    🔍 Submission Details
    IP Address:
    ' . htmlspecialchars($_SERVER['REMOTE_ADDR']) . '
    User Agent:
    ' . htmlspecialchars($_SERVER['HTTP_USER_AGENT']) . '
    Referrer:
    ' . htmlspecialchars($_SERVER['HTTP_REFERER'] ?? 'Direct') . '
    '; // Email headers $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=UTF-8\r\n"; $headers .= "From: \"UK Data Services Quote System\" \r\n"; $headers .= "Reply-To: " . $email . "\r\n"; $headers .= "X-Mailer: PHP/" . phpversion() . "\r\n"; $headers .= "X-Priority: " . ($timeline === 'asap' ? '1' : '3') . "\r\n"; // Create logs directory if it doesn't exist if (!file_exists('logs')) { mkdir('logs', 0755, true); } // Send email try { // Clear any previous errors error_clear_last(); $emailSent = mail($to, $subject, $emailHTML, $headers); if ($emailSent) { // Log successful submission $logEntry = date('Y-m-d H:i:s') . " - Quote request from " . $email . " (" . $_SERVER['REMOTE_ADDR'] . ") - Services: " . implode(', ', $services) . "\n"; file_put_contents('logs/quote-requests.log', $logEntry, FILE_APPEND | LOCK_EX); sendResponse(true, 'Thank you for your quote request! We will send you a detailed proposal within 24 hours.'); } else { // Get detailed error information $lastError = error_get_last(); $errorMsg = $lastError ? $lastError['message'] : 'Unknown mail error'; // Log failed email with detailed error $logEntry = date('Y-m-d H:i:s') . " - FAILED quote request from " . $email . " (" . $_SERVER['REMOTE_ADDR'] . ") - Error: " . $errorMsg . "\n"; file_put_contents('logs/quote-errors.log', $logEntry, FILE_APPEND | LOCK_EX); // Check common issues if (strpos($errorMsg, 'sendmail') !== false) { error_log("Mail server configuration issue: " . $errorMsg); } sendResponse(false, 'There was an error sending your quote request. Please try again or contact us directly at info@ukdataservices.co.uk'); } } catch (Exception $e) { // Log exception with full details $logEntry = date('Y-m-d H:i:s') . " - EXCEPTION: " . $e->getMessage() . " from " . $email . " (" . $_SERVER['REMOTE_ADDR'] . ") - File: " . $e->getFile() . " Line: " . $e->getLine() . "\n"; file_put_contents('logs/quote-errors.log', $logEntry, FILE_APPEND | LOCK_EX); sendResponse(false, 'There was an error processing your quote request. Please contact us directly at info@ukdataservices.co.uk'); } ?>