<?php
include "manager/conn.php";
include "database_tables.php";
include "db_functions.php";
$dataArray=array();
$sSql=mysql_query("select id,name,description from ". TABLE_PAGE ." where pOrder='$contact_pOrder'");
if(mysql_num_rows($sSql)){
while($sSqlResult=mysql_fetch_object($sSql)){
$dataArray[]=array(
                   'id'=>$sSqlResult->id, 
				   'name'=>$sSqlResult->name,
				   'description'=>$sSqlResult->description  
                  );
}
}
//--------------------------------------------------------------------
        $mendatry_check_array=array('fname','email','phone','message');				
        $unset_array=array('submit');
		$validate_check_array=array(												
										'emailValid'=>array(
										  	    array('name'=>'email',	
												'error'=>'Enter Valid email.')),
												
											   'numeric'=>array(
								                     array('name'=>'phone',
													 'error'=>'Phone number must be numeric.'))
											         
							                );	
//------------------------------------------------------------------------											
$mailsent=0;
$fname="";
$email="";
$phone="";
$message="";

  if(count($_POST)){
	
	$post_data=$_POST;	
	$proceed_flag=0;
	$edit_id=0;	
	$errormsg='';	
	extract($post_data);
	list($proceed_flag,$errormsg)=mendatry_check_field($mendatry_check_array,$validate_check_array,$post_data,$edit_id);
	    if($proceed_flag < 1)
		{
		
		 
	  if($mailsent==0){	  		
		$mail_to="test2@ourdemourl.com";	
					
		$mail_subject= "Apply for business loan";	
		$mail_body = "<table style=font:Verdana; font-size:11px; color:#000000><tr><td>";	
		$mail_body = $mail_body ."Name :".$post_data['fname']."<br/>";
		$mail_body = $mail_body ."Email :".$post_data['email']."<br/>";		
		$mail_body = $mail_body ."Phone :".$post_data['phone']."<br/>";		
		$mail_body = $mail_body ."Message :".$post_data['message']."<br/>";			
		$mail_body = $mail_body ."</td></tr></table>";	
			
		$headers =  "Content-Type: text/html;charset=iso-8859-1\n";
		$headers = $headers . "From:".$post_data['email'];	
		
		mail($mail_to,$mail_subject,$mail_body,$headers);	
	    $mailsent=1;
		 }
		}
		else {
	           $haderr="yes";
	           $errormsg = $errormsg;
			   extract($post_data);
	           }
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Heron's Walk : Contact Us</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<script type="text/javascript" src="js.js"></script>
</head>
<body>
<div id="main">
<div id="top">
<img src="images/index_08.png" width="850" height="17" alt=""/>
</div>
<div id="wrapper">
<table width="100%" border="0" cellpadding="0" cellspacing="0">

  <tr>
    <td width="250" id="left">
<?php include "left_menu.php";?>
       </td>
     <td width="530" id="right">
     <!--flash area -->  
     
	<?php include "header.php";?>
  <!--flash area --> 
  <div id="text">
  <h5><?php echo $dataArray[0]['name'];?></h5>
  <p>&nbsp; </p>
  <!--start cms --> 
 <?php echo html_entity_decode($dataArray[0]['description']);?> <!--end cms -->

<p>&nbsp; </p>

<hr />

<p>&nbsp; </p>
<?php if($mailsent==0){?> 
<p>Please fill up the form below if you want to leave a message :</p>
<p class="errFont"><?php 
		                               if(isset($errormsg))
		  	                           {
									   echo $errormsg;
		   	                           }						 
			?> </p>
           
<p>
<form action="" method="post" name="contact" id="contact" class="form-1">

<div>
  <label><span class="errFont">*</span>Your Name</label>
   <input name="fname" type="text"  value="<?php echo $fname;?>" maxlength="40" /></div>

<div>
  <label><span class="errFont">*</span>Email Address</label>
   <input name="email" type="text" value="<?php echo $email;?>" maxlength="40" /></div>

<div>
  <label><span class="errFont">*</span>Phone</label>
   <input name="phone" type="text" value="<?php echo $phone;?>" maxlength="40" /></div>

<div>
  <label><span class="errFont">*</span>Your Message</label>
   <textarea name="message" cols="28" rows="5"><?php echo $message;?></textarea></div>

<div><label>&nbsp;</label> <input name="submit" type="submit" value="Submit" /></div>

</form></p>
 <?php }?> 
  <?php if($mailsent==1){?> 
  <p align="center">Your Mail sent successfully.</p>
    <?php }?> 
  </div>
     </td>
  </tr>
</table>
<?php include "footer.php";?>
<div id="bot">
<img src="images/index_09.png" width="850" height="18" alt=""/>
</div>
</div>
</body>
</html>