<?php
$heading = 'contact';
require_once('includes/header.php');
 
$obj = new DBClass();

$sql = "SELECT * FROM ".TBL_DIRECTORY." WHERE memberID = '".$_REQUEST['id']."'";
$rs = $obj->executeQry($sql,$link);
$row = $obj->fetchrow();

if(isset($_POST['submit']) && $_POST['submit'] == 'Send Enquiry'){

	$valid = checkName($_POST['name'], "Name"); if(isset($valid) && $valid != ''){ $error[] = $valid;}
	$valid = checkEmail($_POST['email'], "Email"); if(isset($valid) && $valid != ''){ $error[] = $valid;}
    $valid = validmess($_POST['contact'], "Contact No."); if(isset($valid) && $valid != ''){ $error[] = $valid;}
    $valid = validmess($_POST['company_name'], "Company Name"); if(isset($valid) && $valid != ''){ $error[] = $valid;}
  		
	if($error == ''){
		$sqll = "INSERT INTO ".TBL_MEMBEENQ." (name,email,contact,company_name,memberID,comment) VALUES ('".trim($_POST['name'])."','".trim($_POST['email'])."','".trim($_POST['contact'])."','".trim($_POST['company_name'])."','".trim($row['memberID'])."','".trim($_POST['comment'])."')";
		$rs2 = $obj->executeQry($sqll,$link);
		if($rs2){
			// *********************** start  mail to admin *****************
	
			$to        	=  @$row['email1'];	
			$subject	    =	"Enquiry About your product";	
			$message	= 	"Enquiry customer Details are  :-               <br><br>".	
			"Name		: ".@$_POST['name']. "  		<br>".	
			"Email Address 	: ".@$_POST['email']. "  	  <br>".			
			"Contact No.		 	: ".@$_POST['contact']. "  	  <br>".			
			"Company Name		 	: ".@$_POST['company_name']. "  	  <br>".			
			"Message	: ".@$_POST['comment']. "  	<br>".			
			 $message  .=  "<br><br><br><br><strong style='font-size:18px;'>Thanks and Regards</strong><br><strong>Shrinetra Infotech</strong><br>62, Sch. No. 114, Part 1<br>Near ICICI Bank ATM,<br>Indore, (M.P) 452010<br><br><strong>Phone &nbsp;&nbsp;:</strong> 0731-2012323<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+91-9993299974-78 (sales)<br><strong>Fax &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: </strong> 0731-4032323<br><strong>Email Id:</strong> shrinetrainfotech@gmail.com<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;info@coalbazaar.com<br><strong>Website:</strong><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;www.coalbazaar.com<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;www.coalmandi.com<br>";
			$headers  = 'MIME-Version: 1.0' . "\r\n";
			$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";				
			$headers .= "From: ".$_POST['name']."<".$_POST['email']."> \r\n";
			$sended=@mail($to, $subject, $message, $headers);	

			@header('Location: contact-us.php?id='.$_REQUEST['id'].'&action=send');
		}
	}
}

 ?>
<div id="page">
	<div id="content">
		<div class="post">

            <table>
						<tr>
								<td><h2><span><?php echo $row['person_name'];?></span></h2></td>
						</tr>
						<tr>
								<td><?php echo $row['address'];?></td>
						</tr>
						<tr>
								<td> <?php echo $row['district'];?> , <?php echo $row['state'];?> - <?php echo $row['pincode'];?></td>
						</tr>
				</table>
				
				<table>
						<tr>
								<td><b>Phone</b></td>
								<td><?php echo $row['phone'];?></td>
						</tr>
						<tr>
								<td>&nbsp;</td>
								<td><?php echo $row['mobile1'];?><b>-</b><?php echo $row['mobile2'];?></td>
						</tr>
						<tr>
								<td><b>Fax</b></td>
								<td><?php echo $row['fax'];?></td>
						</tr>
						<tr>
								<td><b>Email Id</b></td>
								<td><?php echo $row['email1'];?>, <?php echo $row['email2'];?></td>
						</tr>
						<tr>
								<td><b>Web Site</b></td>
								<td><?php echo $row['website'];?></td>
						</tr>
				</table>
				 <div class="margin_bottom_40"></div>
				 
  				<h2><span>For Enquiry</span></h2>
				
				 <?php 
				 	if(isset($_GET['action']) && $_GET['action'] == 'send') { ?>
				 		<b>Your Enquiry Send sucessfully.. <br />Thank you</b>
				<?php  }  else { ?>	
				<form method="POST" action="">
					<table>
						<tr>
							<td><div class="err_msg"><?php ShowError($error); ShowInfo($info);?></div></td>
						</tr>
						<tr>
							<td class="formtxt">Name<span class="sstar">*</span></td>
							<td><input name="name" type="text" class="txt_box2"/></td>    
						</tr>
						<tr>
							<td colspan="2" style="height: 2px;"></td>
						</tr>
						<tr>
							<td class="formtxt">Contact No.<span class="sstar">*</span></td>
							<td><input name="contact" type="text" class="txt_box2"/></td>    
						</tr>
						<tr>
							<td colspan="2" style="height: 2px;"></td>
						</tr>
						 <tr>
							<td class="formtxt">E-mail Address<span class="sstar">*</span></td>
							<td><input name="email" type="text" class="txt_box2"/></td>    
						</tr>
						<tr>
							<td colspan="2" style="height: 2px;"></td>
						</tr>
						 <tr>
							<td class="formtxt">Company Name<span class="sstar">*</span></td>
							<td><input name="company_name" type="text" class="txt_box2"/></td>    
						</tr>
						<tr>
							<td colspan="2" style="height: 2px;"></td>
						</tr>
						<tr>
							<td class="formtxt">Comment</td>
							<td><textarea rows="4" name="comment" class="txt_box2"></textarea></td>    
						</tr>
						<tr>
							<td colspan="2" style="height:10px;"></td>
						</tr>
						<tr>
							<td colspan="2"><input type="submit" name="submit" class="login_btn" value="Send Enquiry" /></td>
						</tr>
						<tr>
							<td colspan="2" style="height: 20px;"></td>
						</tr>
					</table>
				</form>
				<?php } ?>
				 <div class="margin_bottom_20"></div>

 			</div>			
			<br class="clearfix" />
		</div>
		<?php require_once('includes/left_bar.php'); ?>
		<br class="clearfix" />
	</div>
</div>
<?php require_once('includes/footer.php'); ?>
</div> <!-- end of footer wrapper -->
</body>
</html>