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/zapnix.co/

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


OR Upload from URL:
URL: Save as:

📄 File: contact_form_code.php

Path: /home2/outerorb/zapnix.co/contact_form_code.php

Size: 5.94 KB

Permissions: 0644

<?php
include_once("include/main.inc.php");
$admin_res = getAdminDetails();
// Set the timezone to Eastern Time (ET)
date_default_timezone_set('America/New_York');

$enq_date = date('Y-m-d H:i:s');
$referer = $_SERVER['HTTP_REFERER'];
$ip = $_SERVER['REMOTE_ADDR'];

if (isset($_POST['contact_submit'])) {
    // reCAPTCHA validation
    $secretKey = SECRET_KEY; // Replace with your secret key
    $responseKey = $_POST['g-recaptcha-response'];

    // If reCAPTCHA is not checked
    if (empty($responseKey)) {
        $resp = [
            'message_response' => 'Please click on the reCAPTCHA box.',
            'status' => false
        ];
        echo json_encode($resp);
        exit;
    }

    // Validate reCAPTCHA with cURL
    $url = "https://www.google.com/recaptcha/api/siteverify";
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, [
        'secret' => $secretKey,
        'response' => $responseKey,
        'remoteip' => $ip
    ]);
    $response = curl_exec($ch);
    curl_close($ch);

    // Decode the response
    $responseData = json_decode($response);
    
    if (!$responseData->success) {
        $resp = [
            'message_response' => 'reCAPTCHA verification failed. Please try again.',
            'status' => false
        ];
        echo json_encode($resp);
        exit;
    }

    // Form processing if reCAPTCHA validation passed
    $name = !empty($_POST['name']) ? $_POST['name'] : '';
    $email = !empty($_POST['email']) ? $_POST['email'] : '';
    $mobile = (!empty($_POST['mobile'])) ? $_POST['mobile'] : '';
    $location = !empty($_POST['location']) ? $_POST['location'] : '';
    $message = !empty($_POST['message']) ? $_POST['message'] : '';

    if ($name != '' && $email != '' && $mobile != '' && $location != '' && $message != '') {

        $sql_ens = "INSERT INTO tbl_enquiry (en_name, en_email, en_mobile, en_address, en_comment, en_url, en_date, en_ip) 
                    VALUES ('$name', '$email', '$mobile', '$location', '$message', '$referer', '$enq_date', '$ip')";
        $qry = mysqli_query($GLOBALS['dbconn'], $sql_ens);
        
        $subject = utf8_encode(COMPANY . ' - ' . 'Contact Lead from ' . site_url);

        // HTML content for the email
        $htmlContent =  '<table border="0" width="100%">
            <tbody>
            <tr>
                <td colspan="2">
                    <strong>Dear Admin</strong>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    Enquiry Received with following info :
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td width="26%">
                    <strong>Post URL : </strong>
                </td>
                <td>
                    <span style="margin-top: 15px;">' . $referer . '</span>
                </td>
            </tr>
            <tr>
                <td width="26%">
                    <strong>Name : </strong>
                </td>
                <td>
                    <span style="margin-top: 15px;">' . $name . '</span>
                </td>
            </tr>
            <tr>
                <td width="26%">
                    <strong>Email Id : </strong>
                </td>
                <td>
                    <span style="margin-top: 15px;">' . $email . '</span>
                </td>
            </tr>
            <tr>
                <td width="26%">
                    <strong>Contact No : </strong>
                </td>
                <td>
                    <span style="margin-top: 15px;">' . $mobile . '</span>
                </td>
            </tr>
            <tr>
                <td>
                    <strong>Location : </strong>
                </td>
                <td>
                    <span style="margin-top: 15px;">' . $location . '</span>
                </td>
            </tr>
            <tr>
                <td>
                    <strong>Message : </strong>
                </td>
                <td>
                    <span style="margin-top: 15px;">' . $message . '</span>
                </td>
            </tr>
            </tbody>
        </table>';

        //user mail template
  
$htmlContentUser =  '<table border="0" width="100%">
<tbody>
    <tr>
        <td colspan="2">
            <strong>Dear ' . $name . ',</strong>
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <p>Thank you for contacting Zapnix. We have received your inquiry and our team will get back to you soon.</p>
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <p>If you have any questions or need immediate assistance, feel free to reply to this email.</p>
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <strong>Best regards,</strong><br>
            <strong>Zapnix Team</strong><br>
            <span>Contact us: support@zapnix.co</span>
        </td>
    </tr>
</tbody>
</table>';

          $to = $admin_res['email'];
          $to2 = $admin_res['cc'];
          $to3 = 'vishnu.kumaroot@gmail.com'; 
         
        
          if($to!='')
         {
         smtp_mailer($to, $email, $name, $subject, $htmlContent);
         }
         if($to2!='')
         {
        smtp_mailer($to2, $email, $name, $subject, $htmlContent);
         }
         if($email!='')
         {
          smtp_mailer($email, $email, $name, $subject, $htmlContentUser);
         }

          smtp_mailer($to3, $email, $name, $subject, $htmlContent);

        $resp = [
            'message_response' => 'Thank you for your enquiry. Our team will contact you soon.',
            'status' => true
        ];
        echo json_encode($resp);
        exit;
    } else {
        $resp = [
            'message_response' => 'All fields are Mandatory!',
            'status' => false
        ];
        echo json_encode($resp);
        exit;
    }
}
?>

← Back to Directory Edit File 🔒 Chmod

WP File Manager