<?php 
session_start();
if($_REQUEST['contact_name']){
$name=$_REQUEST['contact_name'];
$email=$_REQUEST['contact_email'];
$mobile=$_REQUEST['contact_phone'];
$message=$_REQUEST['contact_msg'];
$sender_ip=$_SERVER["REMOTE_ADDR"];
$utm_source=$_REQUEST['utm_source'];
$captcha=trim($_REQUEST['captcha']);
if($utm_source=='')
{
	$utmsource ='Website';
	$curl = '';
}
else
{
	$utmsource = $utm_source;
	$curl = $_REQUEST['curl'];
}
if(!empty($_SESSION['addoncaptcha']))
{
	$addoncaptcha = $_SESSION['addoncaptcha'];
}
else
{
	$addoncaptcha = '';
}

$_SESSION['addoncaptcha'];

if($captcha == $addoncaptcha){
/*#################Save into DB#############*/
$host = "localhost";
$user = "roiera_in_2020";
$pass = "c2*}QNVLa.Ql";
$dbname = "roiera_in_2020";


$conn = mysqli_connect($host, $user, $pass,$dbname);  

if(!$conn){  

  die('Could not connect: '.mysqli_connect_error());  

}  

//echo 'Connected successfully<br/>';  

$sql = "INSERT INTO tbl_lpenquiry_ppc_whitelabel set uname='$name',utm_source='$utm_source',uphone='$mobile',uemail='$email',umessage='$message',usender_ip='$sender_ip'";  
mysqli_query($conn, $sql);
/*#################Save into DB#############*/
	
include ("class.phpmailer.php");

$mail = new PHPMailer();
          
        $mail->IsSMTP();
        $mail->Host = "zimbra011-ind.megavelocity.net"; // Your Domain Name
          
        $mail->SMTPAuth = true;
	$mail->SMTPSecure = "tls";
        $mail->Port = 587;
        $mail->Username = "info@roimantra.com"; // Your Email ID
        $mail->Password = "Hs&#bKW910F^h25"; // Password of your email id
          
        $mail->From = "info@roimantra.com";
        $mail->FromName = "ROI Mantra";
$mail->FromName = $name;
$mail->AddAddress("krishna@roimantra.com");
$mail->AddAddress("krishna.roimantra@gmail.com");
//$mail->AddAddress("roimantra.leads@gmail.com");
//$mail->AddAddress("logictechindia.digital@gmail.com"); // Email on which you want to send mail 
//$mail->AddCC("info@roimantra.com"); // Email on which you want to send mail
//$mail->AddReplyTo($name, "Support and Help"); //optional

//$mail->AddAddress("heena@roimantra.com");
$mail->IsHTML(true);
$mail->Subject = "Lead: Roimantra PPC Whitelabel";

$Body='<html>
<head>
<title>Roimantra PPC Whitelabel</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="table-layout:fixed;background-color:#f9f9f9" id="bodyTable">
	<tbody>
		<tr>
			<td style="padding-right:10px;padding-left:10px;" align="center" valign="top" id="bodyCell">
				<table border="0" cellpadding="0" cellspacing="0" width="100%" class="space">
									<tbody>
										<tr>
											<td style="font-size:0px;line-height:0px;padding-bottom: 30px;">&nbsp;</td>
										</tr>
									</tbody>
								</table>
				<table border="0" cellpadding="0" cellspacing="0" width="100%" class="wrapperBody" style="max-width:600px">
					<tbody>
						<tr>
							<td align="center" valign="top">
								<table border="0" cellpadding="0" cellspacing="0" width="100%" class="tableCard" style="background-color:#fff;">
									<tbody>
										<tr>
											<td style="font-size:0px;line-height:0px">&nbsp;</td>
										</tr>
										<tr>
											<td style="padding: 15px;background: #fff;box-shadow: 0 0 5px rgb(0 0 0 / 10%);">
												<div class="header_logo">
													<a href="index.html"><img src="https://www.roimantra.com/wp-content/uploads/2019/06/roi-logo-final-2.png" alt="logo"></a>
												</div>
											</td>
										</tr>
										<tr>
											<td style="padding: 15px;padding-bottom: 0px;">
												<p><strong>From:</strong> '.$name.'</p>
												<p><strong>Subject:</strong> Lead: Roimantra PPC Whitelabel</p>
											</td>
										</tr>
										<tr>
											<td style="padding: 30px 15px 0px 15px;">
												<p class="text" style="color:#333;">You have received an enquiry form. Below are the given details:</p>
											</td>
										</tr>
										<tr>
											<td style="padding: 15px 15px 15px 15px;">
												<p class="text" style="color:#333;font-size:18px;"><strong>Message Body:</strong></p>
											</td>
										</tr>
										<tr>
											<td style="padding: 0px 15px 10px 15px;">
												<span style="color:#333;"><strong>Name:</strong></span><span> '.$name.'</span>
											</td>
										</tr>
											<tr>
											<td style="padding: 0px 15px 10px 15px;">
												<span style="color:#333;"><strong>Mobile:</strong></span><span> '.$mobile.'</span>
											</td>
										</tr>
											<tr>
											<td style="padding: 0px 15px 10px 15px;">
												<span style="color:#333;"><strong>E-mail:</strong></span><span> '.$email.'</span>
											</td>
										</tr>
										<tr>
											<td style="padding: 0px 15px 10px 15px;">
												<span style="color:#333;"><strong>Message:</strong></span><span> '.$message.'</span>
											</td>
										</tr>
											<tr>
											<td style="padding: 0px 15px 10px 15px;">
												<span style="color:#333;"><strong>Source:</strong></span><span> '.$utmsource.'</span>
											</td>
										</tr>';

										$Body=$Body.'<tr>
											<td style="padding: 0px 15px 0px 15px;">
												<span style="color:#333;"><strong>Sender IP :</strong></span><span> '.$sender_ip.'</span>
											</td>
										</tr>
										
										<tr>
										
										<tr>
											<td style="font-size:1px;line-height:1px;height:50px;">&nbsp;</td>
										</tr>
									<tr>
											<td style="padding: 0px 15px 0px 15px;">
												<p class="text" style="color:#333;font-size:20px;"><strong>Thanks & Regards</strong></p>
												<p class="text" style="color:#333;"><strong>Roimantra</strong></p>
											</td>
										</tr>
										<tr>
											<td style="font-size:1px;line-height:1px" height="20">&nbsp;</td>
										</tr>
									</tbody>
								</table>
								<table border="0" cellpadding="0" cellspacing="0" width="100%" class="space">
									<tbody>
										<tr>
											<td style="font-size:1px;line-height:1px" height="30">&nbsp;</td>
										</tr>
									</tbody>
								</table>
							</td>
						</tr>
					</tbody>
				</table>
			
			</td>
		</tr>
	</tbody>
</table>
</body>
</html>';

$mail->Body =  $Body;
/* if(!$mail->Send())
{
	$data =array("success"=>2,"msg"=>"<div class='alert alert-danger'>Email not send<button type='button' class='close' data-dismiss='alert' aria-hidden='true' style='margin-top:-5px;'>&times;</button>
                                 </div>");
    echo json_encode($data);
exit();	
//echo $mail->ErrorInfo;
}else{
      $data =array("success"=>1,"msg"=>"Successfully Submited");
     echo json_encode($data);
	exit();		   
//echo"<script>window.location.href='https://roimantra.com/ppc-whitelabel-2/changes/thank-you.html'</script>";
//exit();
}
*/
 $data =array("success"=>1,"msg"=>"Successfully Submited");
     echo json_encode($data);
	exit();
} 
else
{
    $data =array("success"=>3,"msg"=>"Wrong Captcha Pls Refresh");
    echo json_encode($data);
exit();	
}
}

?>