
PK 
<?php
if(!empty($_POST)){
//print_r($_POST); exit;
$name = !empty($_POST['name'])?trim($_POST['name']):"";
$email = !empty($_POST['email'])?trim($_POST['email']):"";
$message = !empty($_POST['message'])?trim($_POST['message']):"";
$file = $_FILES ['file'];
$error_msg = "";
$newfilename = uniqid('img-',false);
$foldername = "uploads/";
$imggg = $function->uploadFile($newfilename, $foldername, 'file');
/*if (isset($_FILES['file']) && $_FILES['file']['size'] > 0) {
$uploads_dir = 'upload';
$tmp_name = $_FILES["file"]["tmp_name"];
$file = uniqid().$_FILES["file"]["name"];
move_uploaded_file($tmp_name, "$uploads_dir/$file");
}*/
function get_client_ip() {
$ipaddress = '';
if (getenv('HTTP_CLIENT_IP'))
$ipaddress = getenv('HTTP_CLIENT_IP');
else if(getenv('HTTP_X_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_X_FORWARDED_FOR');
else if(getenv('HTTP_X_FORWARDED'))
$ipaddress = getenv('HTTP_X_FORWARDED');
else if(getenv('HTTP_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_FORWARDED_FOR');
else if(getenv('HTTP_FORWARDED'))
$ipaddress = getenv('HTTP_FORWARDED');
else if(getenv('REMOTE_ADDR'))
$ipaddress = getenv('REMOTE_ADDR');
else
$ipaddress = 'UNKNOWN';
return $ipaddress;
}
$ipaddress = get_client_ip();
//print_r($_POST); exit;
$pdodb = PDODB::getInstance();
$sql = "INSERT INTO enquiry SET name='".$name."',email='".$email."',ipaddress='".$ipaddress."',message='".$message."',file='".$imggg[2]."'";
$result = $pdodb->query($sql);
PDODB::closeInstance();
if($result) {
$error_msg = "Message Sent Successfully";
}
/*$dbhost = "localhost";
$dbname = "taattva";
$dbusername = "root";
$dbpassword = "";*/
/*$link = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbusername, $dbpassword);
$link->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$statement = $link->prepare("INSERT INTO enquiry(file, name, email, message, ipaddress)
VALUES(:file, :name, :email, :message, :ipaddress)");
//print_r($statement); exit;
$statement->execute(array(
"file" => $file,
"name" => $name,
"email" => $email,
"message" => $message,
"ipaddress" =>$ipaddress
));
if($statement)
$error_msg = "Message Sent Successfully";*/
//mail to admin for contacting users
function sendmail($name,$from,$to,$sendmessage){
$from = 'info@taattva.in';
$to = $to;
$subject = 'Taattva Enquiry';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From:' .$from. "\r\n" .
'Reply-To: ' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$message = $sendmessage;
mail($to, $subject, $message, $headers);
}
if(!empty($message)){
$to="dutta.krishnendu@gmail.com";
$contactmail='<table cellpadding="0" cellspacing="0" style="width:600px; margin:0px auto; color:#7b7b7c; vertical-align:middle; font-family:Arial, Helvetica, sans-serif; font-size:16px;">
<tr>
<td style="text-align:center;"><a href="#"><img src="" /></a></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td style="color:#333;"><strong>Hi, Admin</strong></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>You have been received a query.</td>
</tr>
</table>
<table cellpadding="0" cellspacing="0" style="width:600px; margin:0px auto; color:#7b7b7c; vertical-align:top; font-family:Arial, Helvetica, sans-serif; font-size:14px; line-height:22px;">
<tr>
<td> </td>
</tr>
<tr>
<td style="color:#333;" colspan="3"><strong>Contact Details</strong></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td width="200px;">Name</td>
<td width="20px;">:</td>
<td width="380px;">'.$name.'</td>
</tr>
<tr>
<td width="200px;">Email Address</td>
<td width="20px;">:</td>
<td width="380px;">'.$email.'</td>
</tr>
<tr>
<td width="200px;">Requirements</td>
<td width="20px;">:</td>
<td width="380px;"><p>'.$message.'</p></td>
</tr>
</table>';
//print_r($contactmail); exit;
sendmail($name,$from,$to,$contactmail);
}
// end mail send
?>
<script type="text/javascript">
alert("Sucessfully Submited");
</script>
<?php
}
?>
<div class="row connect-section">
<div class="col-md-12">
<h1 class="text-center heading"><a name="connect">Connect</a></h1>
</div>
<div class="col-md-12">
<div class="contact">
<?=$contactdata[0]['contact_details'];?>
</div>
<!-- <p class="text-center">
+91 9811 206 358 / +91 9899 006 358<br>
922 B, 9th Floor, Hemkunt Chember, 89 Nehru Place, New Delhi - 110019 India. Ph.: +91 11 40073545<br>
58, Block-5, 2nd Floor, Eros Garden, Faridabad - 121009
</p> -->
</div>
<div class="col-md-12">
<form action="" method="POST" id="enquiryform" enctype="multipart/form-data">
<div class="row justify-content-md-center">
<div class="col-md-6">
<div class="form-group">
<input type="text" class="form-control" id="name" name="name" aria-describedby="emailHelp" placeholder="Enter your name">
</div>
</div>
</div>
<div class="row justify-content-md-center">
<div class="col-md-6">
<div class="form-group">
<input type="email" class="form-control" id="email" name="email" aria-describedby="emailHelp" placeholder="Enter your email">
</div>
</div>
</div>
<div class="row justify-content-md-center">
<div class="col-md-6">
<textarea class="form-control" id="message" required="" name="message" rows="4" placeholder="Write to us:"></textarea>
</div>
</div>
<div class="row">
<div class="col-md-3 offset-md-3 order-firs pt-10">
<div class="form-group">
<input type="file" class="form-control-file" name="file" value="Attach Image" id="file">
</div>
</div>
<div class="col-md-2 offset-md-2 pt-10">
<div class="form-group">
<button type="submit" name="send" class="btn btn-secondary btn-sm">SEND</button>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 mx-auto">
<p style="color:red; text-align: center;"><?=(!empty($error_msg))?$error_msg:'';?></p>
</div>
</div>
</form>
</div>
</div>


PK 99