<?php
if(isset($_POST))
{
	$usrName = $_POST['usrName']; 
	$cityFrom=$_POST['cityFrom'];
	$cityTo=$_POST['cityTo'];
	$dtStart=$_POST['dtStart'];
	$dtEnd=$_POST['dtEnd'];
	$mobileNo=$_POST['mobileNo'];
	$emailId=$_POST['emailId'];
	$userComments=$_POST['userComments'];
	
	//Start Message Sending
	$mobno="9764611711,9850488982,9595658514";
	$url="http://www.smsjust.com/blank/sms/user/urlsmstemp.php?username=2waycabs&pass=2waycabs@9876&senderid=WAYCAB&dest_mobileno=".urlencode($mobno)."&tempid=54879&F1=".urlencode($usrName)."&F2=".urlencode($cityFrom)."&F3=".urlencode($cityTo)."&F4=".urlencode($dtStart)."&F5=".urlencode($dtEnd)."&F6=".urlencode($mobileNo)."&F7=".urlencode($emailId)."&response=Y";
	$ch = curl_init();	
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_HEADER, TRUE); 
    curl_setopt($ch, CURLOPT_NOBODY, TRUE); // remove body 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
    $head = curl_exec($ch); 
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 
    curl_close($ch);

	$thnkurl="http://www.smsjust.com/blank/sms/user/urlsmstemp.php?username=2waycabs&pass=2waycabs@9876&senderid=WAYCAB&dest_mobileno=".urlencode($mobileNo)."&tempid=54880&response=Y";
	$thnkch = curl_init();	
    curl_setopt($thnkch, CURLOPT_URL, $thnkurl); 
    curl_setopt($thnkch, CURLOPT_HEADER, TRUE); 
    curl_setopt($thnkch, CURLOPT_NOBODY, TRUE); // remove body 
    curl_setopt($thnkch, CURLOPT_RETURNTRANSFER, TRUE); 
    $head = curl_exec($thnkch); 
    $httpCode = curl_getinfo($thnkch, CURLINFO_HTTP_CODE); 
    curl_close($thnkch);
	

    // Start Email Sending	
	if($usrName != "" && $cityFrom != "" && $cityTo != "" && $dtStart != "" && $dtEnd != "" && $mobileNo != "" && $emailId != "" && $userComments != "") {
		$to = "bookings@2waycabs.com";
		$headers = "From:".$emailId;
		$subject = "Cab Booking";
		$message ="Name : ". $usrName ."\r\n\r\n"."Email : ". $emailId."\r\n\r\n"."Contact No :".$mobileNo."\r\n\r\n"."Place From : ".$cityFrom."\r\n\r\n"."Place To : ".$cityTo."\r\n\r\n"."Start Date : ".$dtStart."\r\n\r\n"."Time : ".$dtEnd."\r\n\r\n"."Comments : ". wordwrap($userComments,70);		
		if(mail($to,$subject,$message,$headers))
		{
			echo json_encode("true");	
		}
		else
		{
			echo json_encode("false");	
		}
	}
	else{
		echo json_encode("false");
	}	
}
?>