<?php 
$pageName = 'Contact US';

require_once('config/config.php');
require_once(CLASS_DIR.'dbClass.php');
require_once(INCLUDES_DIR.'header.php');

include('hitCounter.php');

$obj = new DBClass();

$sql = "SELECT * FROM ".TBL_CONTACT." WHERE status = 0 ORDER BY id DESC";
$rs = $obj->executeQry($sql,$link);
$row = $obj->fetchrow();

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

	$valid = checkName($_POST['name'], "Name"); if(isset($valid) && $valid != ''){ $error[] = $valid;}
	$valid = checkEmail($_POST['email'], "Email"); if(isset($valid) && $valid != ''){ $error[] = $valid;}

	if($error == ''){

		// *********************** start  mail to admin *****************

		$to        	= 	"shrinetrainfotech@gmail.com";
		$subject	=	"coalbazaar contact us";
		$message	= 	"The Details are  :-               <br>".
		"--------------------------------------------------------------------------------<br>".
		"Name		: ".@$_POST['name']. "  		<br>".
		"Email Address 	: ".@$_POST['email']. "  	  <br>".
		"Message	: ".@$_POST['comment']. "  	<br>".
		

		"--------------------------------------------------------------------------------<br>";

		// To send HTML mail, the Content-type header must be set
		$headers  = 'MIME-Version: 1.0' . "\r\n";
		$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
		// Additional headers
		//$headers .= 'To: ' "\r\n";
		$headers .= 'From: '.$_POST['name'].'<'.$_POST['email'].'>' . "\r\n";
		@$sended=mail($to, $subject, $message, $headers);	
			if($sended!='')	
				{
        			@header('Location: contact.php?action=done');
					mysql_query("insert into contacts (name,email,comment) values ('".$_POST['name']."','".$_POST['email']."','".$_POST['comment']."')");
				}
	}
}

?>



<!--workarea start------------------------->
<div class="workarea">
	<div class="workareatop">
		<img src="images/workareatopcorner_03.PNG" alt="" />
	</div>
	<!--workareamid start--------------------->
	<div class="workareamid">
		<div id="floatleft" style="width:590px; float:left;">
			<div class="welcomediv">

                        <h2>Contact Coal Bazaar</h2>
						<table>
								<tr>
										<td><b><font size="4"><?php echo $row['name'];?></font></b></td>
								</tr>
								<tr>
										<td><?php echo $row['address'];?></td>
								</tr>
								<tr>
										<td><?php echo $row['addres1'];?></td>
								</tr>
								<tr>
										<td><?php echo $row['city'].', '.$row['state'].' '.$row['zip'];?></td>
								</tr>
								<tr>
										<td>&nbsp;</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['mobile'];?><b>-</b><?php echo $row['mobile1'];?></td>
								</tr>
								
								<tr>
										<td><b>Email Id</b></td>
										<td><?php echo $row['email'];?></td>
								</tr>
						</table>
						<br /><br />
						
						<?php if(isset($_GET['action']) && $_GET['action'] == 'done') { ?>
								<div class="err_msg">Thanks for showing interest on us,we will revert you soon.</div>
						<?php } else { ?>
						<br />
						<div class="contactform">
							<form name="contact" method="POST" action="">	
								<table>
									<tr>
										<td><div class="err_msg"><?php ShowError($error); ShowInfo($info);?></div></td>
									</tr>
									<tr>
										<td class="formtxt">Name*</td>
										<td><input name="name" type="text" class="txt_box2"/></td>    
									</tr>
									<tr>
										<td colspan="2" style="height: 2px;">&nbsp;</td>
									</tr>
									<tr>
										<td class="formtxt">E-mail Address*</td>
										<td><input name="email" type="text" class="txt_box2"/></td>    
									</tr>
									<tr>
										<td colspan="2" style="height: 2px;">&nbsp;</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: 2px;">&nbsp;</td>
									</tr>
									<tr>
										<td colspan="2"><input type="submit" name="submit" class="login_btn" value="Submit" /></td>
									</tr>
									<tr>
										<td colspan="2" style="height: 20px;">&nbsp;</td>
									</tr>
								</table>
							</form>
						</div>

						<div class="contact_rt">
								<div class="gmap">
								
										<iframe width="545" height="295" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.co.in/maps?hl=en&amp;ie=UTF8&amp;t=m&amp;ll=22.770112,75.900003&amp;spn=0.001187,0.002918&amp;z=18&amp;iwloc=lyrftr:m,3535233191218996050,22.769192,75.899413&amp;output=embed"></iframe><br /><small><a href="https://maps.google.co.in/maps?hl=en&amp;ie=UTF8&amp;t=m&amp;ll=22.770112,75.900003&amp;spn=0.001187,0.002918&amp;z=18&amp;iwloc=lyrftr:m,3535233191218996050,22.769192,75.899413&amp;source=embed" style="color:#0000FF;text-align:left">View Larger Map</a></small>
										
								</div>
						</div>
<?php } ?>




						</div>
				</div>
				<?php require_once(INCLUDES_DIR.'left_bar.php');?>
                <!--floatright close-------------------->
                <div style="clear:both;"></div>
            </div>
            <!--workareamid close--------------------->
            <div class="workareabottom">
                <img src="images/workareabottomcorner_03.PNG" alt="" />
            </div>
        </div>
    <!--workarea close------------------------->
<?php require_once(INCLUDES_DIR.'footer.php');?>