<?php session_start();  //Developed by ITechScripts
error_reporting(0);
require 'include/announcements.php'; // ITECHBIDS Configuration File
require 'include/itechbids.php'; // Server compatibility Patch
	$productid=$_GET['productid'];
		if(isset($_POST['btnSend']))
		{
include_once 'securimage.php';
$securimage = new Securimage();
	$cname=$_POST['txtName'];
	$email=$_POST['txtEmail'];
	$company=$_POST['txtCname'];
	$purpose=$_POST['cboPurpose'];
	$priority=$_POST['cboPriority'];
	$subject=$_POST['txtSubject'];
	$message=$_POST['textfield'];
	$re_user    = "^[a-z0-9\._-]+"; 
$re_delim   = "@"; 
$re_domain  = "[a-z0-9][a-z0-9_-]*(\.[a-z0-9_-]+)*"; 
$re_tld     = "\.([a-z]{2}|aero|arpa|biz|com|coop|edu|gov|info|" . "int|mil|museum|name|net|org|pro)$"; 
$validEmailExpr=$re_user.$re_delim.$re_domain.$re_tld;
if(!empty($email))
{
 if(!eregi($validEmailExpr,$email))
	{
   $err_flag=1;
	}
	}
	if(strlen($cname)==0)
	{
	$nameflag="$err_2";
	$err_flag=1;
	}
	if(strlen($email)==0) 
	{
	$emailflag="$err_2";
	$err_flag=1;
	}
	if(strlen($subject)==0)
	{
	$subjectflag="$err_2";
	$err_flag=1;
	}
	if(strlen($message)==0)
	{
	$messageflag="$err_2";
	$err_flag=1;
	}
    if ($securimage->check($_POST['captcha_code']) == false)
  {
  $err_captcha="Dont match the image";
  $err_flag=1;
  }

	if($err_flag!=1)
	{
	 $res=mysql_query($sql);
	 $row=mysql_fetch_array($res);
	
	$mailfrom=$email;
	$mailSubject=$subject;
	$admin_mail="SELECT * FROM `genaralsettings` WHERE set_id=3";
	$admin_mail_row=mysql_query($admin_mail);
	$admin_mail_res=mysql_fetch_array($admin_mail_row);
	$mailTo=$admin_mail_res['set_value'];
	
	$Message="<table width=50%><tr><td>Company Name:".$company."</td></tr>";
        $Message .="<tr><td>Name:".$cname."</td></tr>";
	$Message .="<tr><td>Purpose:".$purpose."</td></tr>";
	$Message .="<tr><td>Priority:".$priority. "</td></tr>";
	$Message .="<tr><td ><font color=blue>Message:".$message."</blue></td></tr>";
	$mailBody = $Message;
	
	$headers  = "MIME-Version: 1.0\r\n";
	$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
	$headers .= "From: ". $mailfrom."\r\n";	

 if(mail($mailTo,$mailSubject,$mailBody,$headers))
				$status = 1;

}
}
if($status==1)
{  
require 'themes/sucess_contact.tpl';
}
else
{
?>


<?
if($status==1)
{
echo '<b>'.$err_25.'</b>';
}
?>
<? require 'themes/contact.tpl';?>
<?php
	require 'templates/'.$tfold.'/footer.php';
	}
?>
</table>