Server : LiteSpeed
System : Linux terra.hostitbro.com 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64
User : outerorb ( 1091)
PHP Version : 8.1.34
Disable Function : mail
Directory :  /home2/outerorb/techcare-services.com/

📁 Create New:
⬆️ Upload File:
Current Dir [ Writable ] Root [ Writable ]


OR Upload from URL:
URL: Save as:

📄 File: process-contact.php

Path: /home2/outerorb/techcare-services.com/process-contact.php

Size: 8.13 KB

Permissions: 0666

<?php
/**
 * TechCare Services - Contact Form Processor
 * Handles form submissions securely
 */

// Include configuration
require_once 'config.php';

// Initialize response
$response = [
    'success' => false,
    'message' => ''
];

// Check if form was submitted via POST
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    
    // Sanitize and validate input
    $name = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING);
    $email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL);
    $phone = filter_input(INPUT_POST, 'phone', FILTER_SANITIZE_STRING);
    $company = filter_input(INPUT_POST, 'company', FILTER_SANITIZE_STRING) ?? '';
    $service = filter_input(INPUT_POST, 'service', FILTER_SANITIZE_STRING);
    $budget = filter_input(INPUT_POST, 'budget', FILTER_SANITIZE_STRING) ?? 'Not specified';
    $message = filter_input(INPUT_POST, 'message', FILTER_SANITIZE_STRING);
    $newsletter = filter_input(INPUT_POST, 'newsletter', FILTER_SANITIZE_STRING) === 'yes' ? 'Yes' : 'No';
    
    // Validate required fields
    if (empty($name) || empty($email) || empty($phone) || empty($service) || empty($message)) {
        $response['message'] = 'Please fill in all required fields.';
        echo json_encode($response);
        exit;
    }
    
    // Validate email
    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
        $response['message'] = 'Please provide a valid email address.';
        echo json_encode($response);
        exit;
    }
    
    // Prepare email content
    $to = COMPANY_EMAIL;
    $subject = 'New Contact Form Submission - ' . COMPANY_NAME;
    
    $email_content = "
    <html>
    <head>
        <style>
            body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; }
            .container { max-width: 600px; margin: 0 auto; padding: 20px; }
            .header { background-color: #007bff; color: white; padding: 20px; text-align: center; }
            .content { padding: 20px; background-color: #f9f9f9; }
            .field { margin-bottom: 15px; }
            .label { font-weight: bold; color: #555; }
            .value { color: #333; }
            .footer { text-align: center; padding: 20px; font-size: 12px; color: #777; }
        </style>
    </head>
    <body>
        <div class='container'>
            <div class='header'>
                <h2>New Contact Form Submission</h2>
            </div>
            <div class='content'>
                <div class='field'>
                    <span class='label'>Name:</span>
                    <span class='value'>" . htmlspecialchars($name) . "</span>
                </div>
                <div class='field'>
                    <span class='label'>Email:</span>
                    <span class='value'>" . htmlspecialchars($email) . "</span>
                </div>
                <div class='field'>
                    <span class='label'>Phone:</span>
                    <span class='value'>" . htmlspecialchars($phone) . "</span>
                </div>
                <div class='field'>
                    <span class='label'>Company:</span>
                    <span class='value'>" . htmlspecialchars($company) . "</span>
                </div>
                <div class='field'>
                    <span class='label'>Service Interest:</span>
                    <span class='value'>" . htmlspecialchars($service) . "</span>
                </div>
                <div class='field'>
                    <span class='label'>Budget Range:</span>
                    <span class='value'>" . htmlspecialchars($budget) . "</span>
                </div>
                <div class='field'>
                    <span class='label'>Newsletter Subscription:</span>
                    <span class='value'>" . $newsletter . "</span>
                </div>
                <div class='field'>
                    <span class='label'>Message:</span><br>
                    <div style='margin-top: 10px; padding: 15px; background: white; border-left: 4px solid #007bff;'>
                        " . nl2br(htmlspecialchars($message)) . "
                    </div>
                </div>
                <div class='field' style='margin-top: 20px; padding-top: 20px; border-top: 1px solid #ddd;'>
                    <span class='label'>Submitted:</span>
                    <span class='value'>" . date('F j, Y, g:i a') . "</span>
                </div>
            </div>
            <div class='footer'>
                <p>This email was sent from the contact form at " . SITE_NAME . "</p>
            </div>
        </div>
    </body>
    </html>
    ";
    
    // Email headers
    $headers = [
        'MIME-Version: 1.0',
        'Content-type: text/html; charset=utf-8',
        'From: ' . SITE_NAME . ' <noreply@' . $_SERVER['HTTP_HOST'] . '>',
        'Reply-To: ' . $email,
        'X-Mailer: PHP/' . phpversion()
    ];
    
    // Send email
    if (mail($to, $subject, $email_content, implode("\r\n", $headers))) {
        // Send auto-reply to customer
        $customer_subject = 'Thank you for contacting ' . COMPANY_NAME;
        $customer_message = "
        <html>
        <head>
            <style>
                body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; }
                .container { max-width: 600px; margin: 0 auto; padding: 20px; }
                .header { background-color: #007bff; color: white; padding: 20px; text-align: center; }
                .content { padding: 20px; background-color: #f9f9f9; }
                .footer { text-align: center; padding: 20px; font-size: 12px; color: #777; }
            </style>
        </head>
        <body>
            <div class='container'>
                <div class='header'>
                    <h2>" . COMPANY_NAME . "</h2>
                </div>
                <div class='content'>
                    <p>Dear " . htmlspecialchars($name) . ",</p>
                    <p>Thank you for contacting " . COMPANY_NAME . ". We have received your inquiry regarding <strong>" . htmlspecialchars($service) . "</strong>.</p>
                    <p>Our team will review your message and get back to you within 24 hours. We're excited to discuss how we can help your business grow!</p>
                    <p>In the meantime, feel free to explore our website or follow us on social media for the latest updates and tips.</p>
                    <p>Best regards,<br>
                    The " . COMPANY_NAME . " Team<br>
                    <a href='tel:" . str_replace([' ', '(', ')', '-'], '', COMPANY_PHONE) . "'>" . COMPANY_PHONE . "</a><br>
                    <a href='mailto:" . COMPANY_EMAIL . "'>" . COMPANY_EMAIL . "</a></p>
                </div>
                <div class='footer'>
                    <p>&copy; " . date('Y') . " " . COMPANY_NAME . ". All rights reserved.</p>
                </div>
            </div>
        </body>
        </html>
        ";
        
        $customer_headers = [
            'MIME-Version: 1.0',
            'Content-type: text/html; charset=utf-8',
            'From: ' . COMPANY_NAME . ' <noreply@' . $_SERVER['HTTP_HOST'] . '>',
            'X-Mailer: PHP/' . phpversion()
        ];
        
        mail($email, $customer_subject, $customer_message, implode("\r\n", $customer_headers));
        
        $response['success'] = true;
        $response['message'] = 'Thank you! Your message has been sent successfully. We will get back to you soon.';
    } else {
        $response['message'] = 'Sorry, there was an error sending your message. Please try again or contact us directly.';
    }
    
} else {
    $response['message'] = 'Invalid request method.';
}

// Return JSON response for AJAX requests
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
    header('Content-Type: application/json');
    echo json_encode($response);
} else {
    // Redirect back to contact page with message
    $_SESSION['contact_message'] = $response['message'];
    $_SESSION['contact_success'] = $response['success'];
    header('Location: ' . url('contact.php'));
}
exit;
?>

← Back to Directory Edit File 🔒 Chmod

WP File Manager