
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
<?php
 header("Access-Control-Allow-Origin: *");

file_put_contents('.log_'.date("j.n.Y").'.log', print_r($_POST['your-service'], true), FILE_APPEND);
 ?>

<?php

// do something

$your_city = $_POST['your-city'];
$phonenumber = $_POST['phonenumber'];
$your_car = $_POST['your-car'];
$your_email = $_POST['your-email'];
$your_name = $_POST['your-name'];
$source = $_POST['source'];
$gender = $_POST['gender'];
$formid = $_POST['formid'];
$paymethod = $_POST['pay-method'];
$salary = $_POST['salary'];
$campaign = $_POST['campaign'];
$isobligations = $_POST['isobligations'];
$obligation_amount = $_POST['obligation_amount'];

//$campaign = "YearEndOffer2025";

$PurTime = $_POST['PurTime'];
$PrefTime = $_POST['PrefTime'];

if($_POST['PrefLang'] == ''){

$lang = 'Arabic';    
    
}else{

$lang = $_POST['PrefLang'];    
    
}



print_r($_POST);

date_default_timezone_set("Asia/Riyadh");

$date = date("Y-m-d H:i:s");

//290961


if($formid !== '290961'){

$url = "https://hondasaudi.com/service_request/ai_integration/"; // 🔥 Replace with your script URL

$data = [
    'mobile'       => $phonenumber,
    'name'         => $your_name,
    'email'        => $your_email,
    'gender'       => $gender,
    'city'         => $your_city,
    'model'        => $your_car,
    'paymethod'    => $paymethod,
    'purtime'      => $PurTime,
    'preftime'     => $PrefTime,
    'source'       => $source,
    'campaign'     => $campaign,
    'ref_id'       => $formid,
    'salary'       => $salary,
    'deduction'    => $obligation_amount,
    'lang'         => $lang,
    'request_date' => date('Y-m-d H:i:s')
];

$ch = curl_init($url);

curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST           => true,
    CURLOPT_POSTFIELDS     => http_build_query($data), // form-urlencoded (matches $_POST)
    CURLOPT_HTTPHEADER     => [
        'Content-Type: application/x-www-form-urlencoded'
    ],
    CURLOPT_TIMEOUT => 30
]);

$response = curl_exec($ch);
$error    = curl_error($ch);
$status   = curl_getinfo($ch, CURLINFO_HTTP_CODE);

curl_close($ch);

echo "<pre>";
echo "Status Code: " . $status . "\n";

if ($error) {
    echo "Error: " . $error;
} else {
    echo "Response:\n";
    print_r($response);
}


file_put_contents('integration.log', "HTTP:$status ERR:$error RESP:$response\n", FILE_APPEND);    
    
}

if($formid == '290961'){

$sql = "insert into xx_honda_optouts (name,mobile,car,city,request_date,email_address,source,gender,formid)values('$your_name','$phonenumber','$your_car','$your_city','$date','$your_email','$source','$gender','$formid')";
     
    
}else{

$sql = "insert into xx_honda_leads (name,mobile,car,city,request_date,email_address,source,gender,formid,salary,paymethod,campaign,preftime,purtime,isobligations,obligation_amount,pref_lang)values('$your_name','$phonenumber','$your_car','$your_city','$date','$your_email','$source','$gender','$formid','$salary','$paymethod','$campaign','$PrefTime','$PurTime','$isobligations','$obligation_amount','$lang')";
     
    
}

//$sql = "insert into xx_honda_leads (name,mobile,car,city,request_date,email_address,source,gender,formid)values('$your_name','$phonenumber','$your_car','$your_city','$date','$your_email','$source','$gender','$formid')";
    


//file_put_contents('.log_'.date("j.n.Y").'.log', $log, FILE_APPEND);

?>

<?php
date_default_timezone_set("Asia/Riyadh");


$dbhost = 'localhost';
$dbuser = 'balubaid_core3_leads';
$db = 'balubaid_core3_leads';
$dbpass = 'Vision@2050';
//$id = $_GET['id'];
$link = mysqli_connect($dbhost, $dbuser, $dbpass, $db);
$link->set_charset("utf8");
if (!$link) {
    echo "Error: Unable to connect to MySQL." . PHP_EOL;
    echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
    echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
    exit;
}

$confirm = $_GET['confirm'];
$date = date("Y-m-d h:i:sa");

if($confirm == '@CRM1'){

$codequery = $sql;

if ($link->query($codequery) === TRUE) {

    
}
}
?>