File: /var/www/html/sarvodayahospital/public/services/rheumatology/callBack.php
<?php
use Phppot\DataSource;
require_once 'DataSource.php';
$db = new DataSource();
$conn = $db->getConnection();
if ($_POST['name']!='' && $_POST['phone'] !='') {
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$query = $_POST['query'];
date_default_timezone_set("Asia/Calcutta");
$date = date('Y-m-d h:i:s');
$utm_campaign = $_POST['utm_campaign'];
$utm_medium = $_POST['utm_medium'];
$utm_source = $_POST['utm_source'];
$insertQuery = "INSERT into rheumatology
(customer_name, customer_email, customer_phone, customer_enquiry, date, utm_source, utm_campaign, utm_medium )
values ('$name','$email','$phone','$query', '$date', '$utm_source', '$utm_campaign', '$utm_medium')";
$insertQueryId = $db->insert($insertQuery);
$message = '<html><body style="max-width:800px;width:100%;margin:0px auto;"><div style="width:100%; margin:0px auto;">';
$message .= '<div style="display:inline-block; width:100%;text-align:center;font-family: Helvetica, Arial, sans-serif;"><div style="padding-top:20px;padding-bottom:20px"><span style=" text-align: center;font-family: Helvetica, Arial, sans-serif; color: rgb(53, 59, 70);
font-size: 24px; line-height: 28px; font-weight: bold;"><b>Lead Details- Sarvodaya Rheumatology Leads</b></span>
<hr style="color: #D00B12; border: 3px solid; max-width: 60px; margin: 15px auto;"><div style="max-width:550px;margin:20px auto;text-align: center; color: #7c7f87; font-size: 14px; line-height: 20px; font-weight: normal;">
Name : '.$name.'<br>
Email : '.$email.'<br>
Phone : '.$phone.'<br>
Query : '.$query.'<br>
Campaign : '.$utm_campaign.'<br>
Medium : '.$utm_medium.'<br>
Source : '.$utm_source.'<br>
<br><br><br></div></div><div style="background-color: #f7f8fa;text-align: center; color: #000; font-size: 13px; line-height: 20px; font-weight: 300;padding:20px;"><div style="max-width:600px;margin:0px auto;font-family: Helvetica, Arial, sans-serif;">Copyright 2022. All Rights Reserved. Sarvodaya Imaging</div>
</div></div>';
$message .= '</div></body></html>';
$subject = "Rheumatology Leads || Sarvodaya Hospital";
require 'vendor/autoload.php';
$sendgrid_apikey = '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';
$sendgrid = new SendGrid($sendgrid_apikey);
$url = 'https://api.sendgrid.com/';
$pass = $sendgrid_apikey;
$params = array(
'to[0]' => "helpdesk@sarvodayahospital.com",
'to[1]' => "sampada.atri@sarvodayahospital.com",
'to[2]' => "digital@gyanwave.com",
'to[3]' => "sunil@gyanwave.com",
'to[4]' => "nandini@gyanwave.com",
'bcc' => "vicky@gyanwave.com",
'bccname' => "Vicky",
'from' => "info@sarvodayahospital.com",
'fromname' => "Sarvodaya Hospital",
'subject' => $subject,
'text' => "I'm text!",
'html' => $message,
);
/*
$params = array(
'to[0]' => "digital@gyanwave.com",
'to[1]' => "sunil@gyanwave.com",
'to[2]' => "ankush@gyanwave.com",
'cc' => "sampada.atri@sarvodayahospital.com",
'ccname' => "Sampada Atri",
'bcc' => "vicky@gyanwave.com",
'bccname' => "Vicky",
'from' => "info@sarvodayaimaging.com",
'fromname' => "Sarvodaya",
'subject' => $subject,
'text' => "I'm text!",
'html' => $message,
);
*/
$request = $url.'api/mail.send.json';
// Generate curl request
$session = curl_init($request);
// Tell PHP not to use SSLv3 (instead opting for TLS)
curl_setopt($session, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
curl_setopt($session, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $sendgrid_apikey));
// Tell curl to use HTTP POST
curl_setopt ($session, CURLOPT_POST, true);
// Tell curl that this is the body of the POST
curl_setopt ($session, CURLOPT_POSTFIELDS, $params);
// Tell curl not to return headers, but do return the response
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// obtain response
$response = curl_exec($session);
curl_close($session);
// print everything out
$data = json_decode($response);
if($data->message == 'success'){
header("Location: https://sarvodayahospital.com/services/rheumatology/thank-you.html");
exit();
}else{
header("Location: https://sarvodayahospital.com/services/rheumatology/failed.html");
exit();
}
/*
$heading = "Opps!";
$error = 'Unable to handle your request!';
if(!empty($_POST)) {
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
// Compose a simple HTML email message
$message = '<html><body style="max-width:800px;width:100%;margin:0px auto;"><div style="width:100%; margin:0px auto;">';
$message .= '<div style="display:inline-block; width:100%;text-align:center;font-family: Helvetica, Arial, sans-serif;"><div style="padding-top:20px;padding-bottom:20px"><span style=" text-align: center;font-family: Helvetica, Arial, sans-serif; color: rgb(53, 59, 70);
font-size: 24px; line-height: 28px; font-weight: bold;"><b>IVF Enquiry Details- Sarvodaya Imaging</b></span>
<hr style="color: #D00B12; border: 3px solid; max-width: 60px; margin: 15px auto;"><div style="max-width:550px;margin:20px auto;text-align: center; color: #7c7f87; font-size: 14px; line-height: 20px; font-weight: normal;">
Name : '.$name.'<br>
Email : '.$email.'<br>
Phone : '.$phone.'<br><br><br><br></div></div><div style="background-color: #f7f8fa;text-align: center; color: #000; font-size: 13px; line-height: 20px; font-weight: 300;padding:20px;"><div style="max-width:600px;margin:0px auto;font-family: Helvetica, Arial, sans-serif;">Copyright 2022. All Rights Reserved. Sarvodaya Imaging</div>
</div></div>';
$message .= '</div></body></html>';
$subject = "IMG Leads";
require 'vendor/autoload.php';
$email = new \SendGrid\Mail\Mail();
$email->setFrom("admin@maxhealthcare.com", "IVF Enquiry");
$email->setSubject($subject);
$email->addTo('ravikant@gyanwave.com', 'Ravi kant');
$email->addContent("text/html", $message);
$sendgrid = new \SendGrid("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");
try {
$response = $sendgrid->send($email);
$heading = "Thank You!";
$error = "Your submission has been received and we will contact you soon";
} catch (Exception $e) {
echo "Caught exception: ". $e->getMessage() ."\n";
print "<script>";
print "alert('Something wrong with you try again !')";
print "</script>";
$heading = "Opps!";
$error = 'Something wrong please try again';
exit;
}
}*/
$data['success'] = true;
$data['message'] = $error;
}
?>