Skip to content

Instantly share code, notes, and snippets.

@accessomnath
Created June 15, 2016 12:30
Show Gist options
  • Save accessomnath/960df8009c9b8afeecd59d693e42d90f to your computer and use it in GitHub Desktop.
Save accessomnath/960df8009c9b8afeecd59d693e42d90f to your computer and use it in GitHub Desktop.
<?php
/* template name: business-questionnaire */
get_header();
if(isset($_GET['resp']) && $_GET['resp'] == 'success'){?>
<div class="alert alert-info" role="alert">
<span class="glyphicon glyphicon-exclamation-ok" aria-hidden="true"></span>
<span class="sr-only">Success:</span>
Thank you for contacting Us!
</div>
<?php
}
?>
<div class="container">
<div class="row well">
<div class="col-md-12">
<form name="myForm" enctype="multipart/form-data" action="" method="post">
<div class="form-group">
First Name:<span class="requerd">*</span>
<input class="form-control" name="myFirstName" ng-model="myFirstName" required>
<span
ng-show="myForm.myFirstName.$touched && myForm.myFirstName.$invalid">First name is required.</span>
</div>
<div class="form-group">
Last Name:<span class="requerd">*</span>
<input class="form-control" name="myLastName" ng-model="myLastName" required>
<span
ng-show="myForm.myLastName.$touched && myForm.myLastName.$invalid">Last name is required.</span>
</div>
<div class="form-group">
Email Address:<span class="requerd">*</span>
<input class="form-control" name="myEmail" ng-model="myEmail" required type="email" style=" width: 100%;">
<span ng-show="myForm.myEmail.$touched && myForm.myEmail.$invalid">Email is required.</span>
</div>
<div class="form-group">
Phone Number:<span class="requerd">*</span>
<input class="form-control" type="number" name="myPhone" ng-model="myPhone" required>
<span ng-show="myForm.myPhone.$touched && myForm.myPhone.$invalid">Phone is required.</span>
</div>
<div class="form-group">
Address Line 1:<span class="requerd">*</span>
<input class="form-control" name="myAddressOne" ng-model="myAddressOne" required>
<span ng-show="myForm.myAddressOne.$touched && myForm.myAddressOne.$invalid">First Address is required.</span>
</div>
<div class="form-group">
Address Line 2:<span class="requerd">*</span>
<input class="form-control" name="myAddressTwo" ng-model="myAddressTwo" required>
<span ng-show="myForm.myAddressTwo.$touched && myForm.myAddressTwo.$invalid">Second Address is required.</span>
</div>
<label class="control-label" for="inputSuccess1">Services</label>
<div class="checkbox">
<label class="checkbox-inline">
<input type="checkbox" name="services[]" id="services" value="Business Formation">
Business Formation
</label>
<label class="checkbox-inline">
<input type="checkbox" name="services[]" id="services" value="Tax Consultation">
Tax Consultation
</label>
<label class="checkbox-inline">
<input type="checkbox" name="services[]" id="services" value="Business Strategy">
Business Strategy
</label>
<label class="checkbox-inline">
<input type="checkbox" name="services[]" id="services" value="Sales and Product evaluation">
Sales and Product evaluation
</label>
</div>
<label class="control-label" for="inputSuccess1">Consultant Division</label>
<div class="checkbox">
<label class="checkbox-inline">
<input type="checkbox" name="consultantDivision[]" id="consultantDivision"
value="IT Contractor">
IT Contractor
</label>
<label class="checkbox-inline">
<input type="checkbox" name="consultantDivision[]" id="consultantDivision"
value="Training Services">
Training Services
</label>
<label class="checkbox-inline">
<input type="checkbox" name="consultantDivision[]" id="consultantDivision"
value="Project Management">
Project Management
</label>
<label class="checkbox-inline">
<input type="checkbox" name="consultantDivision[]" id="consultantDivision"
value="Pharma Manufacturing">
Pharma Manufacturing
</label>
<label class="checkbox-inline">
<input type="checkbox" name="consultantDivision[]" id="consultantDivision"
value="Package Manufacturing">
Package Manufacturing
</label>
<label class="checkbox-inline">
<input type="checkbox" name="consultantDivision[]" id="consultantDivision"
value="Media Development">
Media Development
</label>
</div>
<div class="checkbox">
<label class="checkbox-inline">
<input type="checkbox" name="consultantDivision[]" id="consultantDivision"
value="Industrial Manufacturing">
Industrial Manufacturing
</label>
<label class="checkbox-inline">
<input type="checkbox" name="consultantDivision[]" id="consultantDivision"
value="General Consultant">
General Consultant
</label>
</div>
<label class="control-label" for="inputSuccess1">Pharma Compliance </label>
<div class="checkbox">
<label class="checkbox-inline">
<input type="checkbox" name="pharmaCompliance[]" id="pharmaCompliance" value="DEA Audit">
DEA Audit
</label>
<label class="checkbox-inline">
<input type="checkbox" name="pharmaCompliance[]" id="pharmaCompliance" value="DEA Prep">
DEA Prep
</label>
<label class="checkbox-inline">
<input type="checkbox" name="pharmaCompliance[]" id="pharmaCompliance" value="Pharma Process">
Pharma Process
</label>
<label class="checkbox-inline">
<input type="checkbox" name="pharmaCompliance[]" id="pharmaCompliance"
value="Quality Assurance Audit">
Quality Assurance Audit
</label>
<label class="checkbox-inline">
<input type="checkbox" name="pharmaCompliance[]" id="pharmaCompliance" value="GMP Audits">
GMP Audits
</label>
</div>
<label class="control-label" for="inputSuccess1">Training</label>
<div class="checkbox">
<label class="checkbox-inline">
<input type="checkbox" name="training[]" id="training" value="Project Management">
Project Management
</label>
<label class="checkbox-inline">
<input type="checkbox" name="training[]" id="training" value="GMP Training">
GMP Training
</label>
<label class="checkbox-inline">
<input type="checkbox" name="training[]" id="training" value="Business Process Development">
Business Process Development
</label>
<label class="checkbox-inline">
<input type="checkbox" name="training[]" id="training" value="Customized">
Customized
</label>
<label class="checkbox-inline">
<input type="checkbox" name="training[]" id="training" value="Leadership">
Leadership
</label>
<label class="checkbox-inline">
<input type="checkbox" name="training[]" id="training" value="Team Building Activies">
Team Building Activies
</label>
</div>
<div class="checkbox">
<label class="checkbox-inline">
<input type="checkbox" name="training[]" id="training" value="Financial Training (third party)">
Financial Training (third party)
</label>
</div>
<label class="control-label" for="inputSuccess1">Financial Services</label>
<div class="checkbox">
<label class="checkbox-inline">
<input type="checkbox" name="financialServices[]" id="financialServices" value="Life Insurance">
Life Insurance
</label>
<label class="checkbox-inline">
<input type="checkbox" name="financialServices[]" id="financialServices" value="Wills">
Wills
</label>
<label class="checkbox-inline">
<input type="checkbox" name="financialServices[]" id="financialServices" value="Annuities">
Annuities
</label>
<label class="checkbox-inline">
<input type="checkbox" name="financialServices[]" id="financialServices"
value="Real Estate Financing">
Real Estate Financing
</label>
<label class="checkbox-inline">
<input type="checkbox" name="financialServices[]" id="financialServices"
value="Business Financing">
Business Financing
</label>
<label class="checkbox-inline">
<input type="checkbox" name="financialServices[]" id="financialServices"
value="Credit Improvement Tools">
Credit Improvement Tools
</label>
</div>
<label class="control-label" for="inputSuccess1">Marketing Services</label>
<div class="checkbox">
<label class="checkbox-inline">
<input type="checkbox" name="marketingServices[]" id="marketingServices" value="Graphics">
Graphics
</label>
<label class="checkbox-inline">
<input type="checkbox" name="marketingServices[]" id="marketingServices" value="Rebranding">
Rebranding
</label>
<label class="checkbox-inline">
<input type="checkbox" name="marketingServices[]" id="marketingServices" value="Web Services">
Web Services
</label>
<label class="checkbox-inline">
<input type="checkbox" name="marketingServices[]" id="marketingServices"
value="E-mail Marketing Campaign">
E-mail Marketing Campaign
</label>
<label class="checkbox-inline">
<input type="checkbox" name="marketingServices[]" id="marketingServices" value="AP Development">
AP Development
</label>
</div>
<input type="submit" name="submit" ng-click="submitted=true" class="btn btn-primary btn-large" value="Submit">
</form>
</div>
</div>
</div>
<?php
if (isset($_POST['submit'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "bguyiii@gmail.com, nsomnathswadesh@gmail.com";
$email_subject = "Business Questionnaire";
function died($error)
{
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error . "<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if (!isset($_POST['myFirstName']) ||
!isset($_POST['myLastName']) ||
!isset($_POST['myEmail']) ||
!isset($_POST['myPhone']) ||
!isset($_POST['myAddressOne']) ||
!isset($_POST['myAddressTwo'])
) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$first_name = $_POST['myFirstName']; // required
$last_name = $_POST['myLastName']; // required
$email = $_POST['myEmail']; // required
$phone = $_POST['myPhone']; // required
$addressOne = $_POST['myAddressOne']; // required
$addressTwo = $_POST['myAddressTwo']; // required
$services = $_POST['services'];
if (isset($services) && count($services) > 0) {
$services = implode(',', $services);
} else {
$services = '';
}
$consultDivision = $_POST['consultantDivision'];
if (isset($consultDivision) && count($consultDivision) > 0) {
$consultDivision = implode(',', $consultDivision);
} else {
$consultDivision = '';
}
$pharmaCompliance = $_POST['pharmaCompliance'];
if (isset($pharmaCompliance) && count($pharmaCompliance) > 0) {
$pharmaCompliance = implode(',', $pharmaCompliance);
} else {
$pharmaCompliance = '';
}
$training = $_POST['training'];
if (isset($training) && count($training) > 0) {
$training = implode(',', $training);
} else {
$training = '';
}
$financialServices = $_POST['financialServices'];
if (isset($financialServices) && count($financialServices) > 0) {
$financialServices = implode(',', $financialServices);
} else {
$financialServices = '';
}
$marketingServices = $_POST['marketingServices'];
if (isset($marketingServices) && count($marketingServices) > 0) {
$marketingServices = implode(',', $marketingServices);
} else {
$marketingServices = '';
}
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if (!preg_match($email_exp, $email)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if (!preg_match($string_exp, $first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if (strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string)
{
$bad = array("content-type", "bcc:", "to:", "cc:", "href");
return str_replace($bad, "", $string);
}
$email_message = "Hello Admin, You have got a new contact with following details: \n\n";
$email_message .= "First Name : " . clean_string($first_name) . "\n";
$email_message .= "Last Name : " . clean_string($last_name) . "\n";
$email_message .= "Email : " . clean_string($email) . "\n";
$email_message .= "Phone : " . clean_string($phone) . "\n";
$email_message .= "Address one : " . clean_string($addressOne) . "\n";
$email_message .= "Address two : " . clean_string($addressTwo) . "\n";
$email_message .= "Services : " . clean_string($services) . "\n";
$email_message .= "Consultant division : " . clean_string($consultDivision) . "\n";
$email_message .= "Pharma Compliance : " . clean_string($pharmaCompliance) . "\n";
$email_message .= "Training : " . clean_string($training) . "\n";
$email_message .= "Financial service : " . clean_string($financialServices) . "\n";
$email_message .= "Marketing service : " . clean_string($marketingServices) . "\n\n\n";
$email_message .="Thanks & Regards, \n" . $first_name ." ". $last_name ;
// create email headers
$headers = 'From: ' . $email . "\r\n" .
'Reply-To: ' . $email . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$mail= @mail($email_to, $email_subject, $email_message, $headers);
echo $mail ? "Thank you for connecting with us! We will contact you shortly!" : "Mail failed";
}
?>
<?php
/* template name: real-estate-questionnaire */
get_header();
if(isset($_GET['resp']) && $_GET['resp'] == 'success'){?>
<div class="alert alert-info" role="alert">
<span class="glyphicon glyphicon-exclamation-ok" aria-hidden="true"></span>
<span class="sr-only">Success:</span>
Thank you for contacting Us!
</div>
<?php
}
?>
<div class="container">
<div class="row well">
<div class="col-md-12">
<form name="myForm" enctype="multipart/form-data" action="" method="post">
<div class="form-group">
First Name:<span class="requerd">*</span>
<input class="form-control" name="myFirstName" ng-model="myFirstName" required>
<span ng-show="myForm.myFirstName.$touched && myForm.myFirstName.$invalid">First name is required.</span>
</div>
<div class="form-group">
Last Name:<span class="requerd">*</span>
<input class="form-control" name="myLastName" ng-model="myLastName" required>
<span ng-show="myForm.myLastName.$touched && myForm.myLastName.$invalid">Last name is required.</span>
</div>
<div class="form-group">
Email Address:<span class="requerd">*</span>
<input class="form-control" name="myEmail" ng-model="myEmail" required type="email" style=" width: 100%;">
<span ng-show="myForm.myEmail.$touched && myForm.myEmail.$invalid">Email is required.</span>
</div>
<div class="form-group">
Phone Number:<span class="requerd">*</span>
<input type="number" class="form-control" name="myPhone" ng-model="myPhone" required >
<span ng-show="myForm.myPhone.$touched && myForm.myPhone.$invalid">Phone is required.</span>
</div>
<div class="form-group">
Address Line 1:<span class="requerd">*</span>
<input class="form-control" name="myAddressOne" ng-model="myAddressOne" required>
<span ng-show="myForm.myAddressOne.$touched && myForm.myAddressOne.$invalid">First Address is required.</span>
</div>
<div class="form-group">
Address Line 2:<span class="requerd">*</span>
<input class="form-control" name="myAddressTwo" ng-model="myAddressTwo" required>
<span ng-show="myForm.myAddressTwo.$touched && myForm.myAddressTwo.$invalid">Second Address is required.</span>
</div>
<label class="control-label" for="realEstateInterest">Real Estate interest</label>
<div class="checkbox">
<label class="checkbox-inline">
<input type="checkbox" name="realEstateInterest[]" id="realEstateInterest" value="residential">
Residential
</label>
<label class="checkbox-inline">
<input type="checkbox" name="realEstateInterest[]" value="Mix Use">
Mix Use
</label>
<label class="checkbox-inline">
<input type="checkbox" name="realEstateInterest[]" value="Multi Family">
Multi-Family
</label>
<label class="checkbox-inline">
<input type="checkbox" name="realEstateInterest[]" value="Commercial">
Commercial
</label>
<label class="checkbox-inline">
<input type="checkbox" name="realEstateInterest[]" value="Hotel">
Hotel
</label>
<label class="checkbox-inline">
<input type="checkbox" name="realEstateInterest[]" value="Land">
Land
</label>
<label class="checkbox-inline">
<input type="checkbox" name="realEstateInterest[]" value="Other">
Other
</label>
</div>
<label class="control-label" for="purchase_requirements">Purchase Requirements</label>
<div class="checkbox">
<label class="checkbox-inline">
<input type="checkbox" name="purchase_requirements[]" value="Cash Buyers">
Cash Buyers
</label>
<label class="checkbox-inline">
<input type="checkbox" name="purchase_requirements[]" value="Hard Money">
Hard Money
</label>
<label class="checkbox-inline">
<input type="checkbox" name="purchase_requirements[]" value="Commercial Financing">
Commercial Financing
</label>
<label class="checkbox-inline">
<input type="checkbox" name="purchase_requirements[]" value="Residential Financing">
Residential Financing
</label>
<label class="checkbox-inline">
<input type="checkbox" name="purchase_requirements[]" value="Real Estate Trust">
Real Estate Trust
</label>
<label class="checkbox-inline">
<input type="checkbox" name="purchase_requirements[]" value="Business Financing">
Business Financing
</label>
<label class="checkbox-inline">
<input type="checkbox" name="purchase_requirements[]" value="Other Financing">
Other Financing
</label>
</div>
<label class="control-label" for="proofFunds">Proof of Funds</label>
<div class="radio">
<label>
<input type="radio" ng-model="proofFunds" name="proofFunds" id="proofFunds" value="1" >
Yes
</label>
</div>
<div class="radio">
<label>
<input type="radio" ng-model="proofFunds" name="proofFunds" id="proofFunds" value="0" checked>
No
</label>
<div class="form-group" ng-show="proofFunds == '1'">
Attach:
<input type="file" id="proof" name="proof">
</div>
</div>
<label class="control-label" for="realEstateAgent">Real Estate Agent</label>
<div class="radio">
<label>
<input type="radio" name="realEstateAgent" ng-model="realEstateAgent" id="realEstateAgent" value="1" >
Yes
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="realEstateAgent" ng-model="realEstateAgent" id="realEstateAgent" value="0">
No
</label>
<div class="form-group" ng-show="realEstateAgent == '1'">
Commission Rate:
<input class="form-control" name="commission_rate" ng-model="commission_rate" >
</div>
<div class="form-group" ng-show="realEstateAgent == '0'">
Do you need one:
<input class="form-control" name="doYouNeedOne" ng-model="doYouNeedOne" >
</div>
</div>
<label class="control-label" for="inputSuccess1">Closing (pick all applicable)</label>
<div class="checkbox">
<label class="checkbox-inline">
<input type="checkbox" name="closing[]" value="lawyer">
Lawyer
</label>
<label class="checkbox-inline">
<input type="checkbox" name="closing[]" value="title company">
Title Company
</label>
<label class="checkbox-inline">
<input type="checkbox" name="closing[]" value="person HUD-1">
Person HUD-1
</label>
<label class="checkbox-inline">
<input type="checkbox" name="closing[]" value="other">
Other
</label>
</div>
<input type="submit" name="submit" ng-click="submitted=true" class="btn btn-primary btn-large" value="submit">
</form>
</div>
</div>
</div>
</div>
<?php
if (isset($_POST['submit'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "bguyiii@gmail.com, nsomnathswadesh@gmail.com";
$email_subject = "Real estate enquery";
function died($error)
{
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error . "<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if (!isset($_POST['myFirstName']) ||
!isset($_POST['myLastName']) ||
!isset($_POST['myEmail']) ||
!isset($_POST['myPhone']) ||
!isset($_POST['myAddressOne'])||
!isset($_POST['myAddressTwo']))
{
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$first_name = $_POST['myFirstName']; // required
$last_name = $_POST['myLastName']; // required
$email = $_POST['myEmail']; // required
$phone = $_POST['myPhone']; // required
$addressOne = $_POST['myAddressOne']; // required
$addressTwo = $_POST['myAddressTwo']; // required
$realEstateInterest = $_POST['realEstateInterest'];
if (isset($realEstateInterest) && count($realEstateInterest) > 0) {
$realEstateInterest = implode(',', $realEstateInterest);
} else {
$realEstateInterest = '';
}
$purchaseReqirement = $_POST['purchase_requirements'];
if (isset($purchaseReqirement) && count($purchaseReqirement) > 0) {
$purchaseReqirement = implode(',', $purchaseReqirement);
} else {
$purchaseReqirement = '';
}
$proofOfFunds = $_POST['proofFunds'];
$proof= $_POST['proof'];
if (isset($proofOfFunds) && $proofOfFunds == 1) {
move_uploaded_file($_FILES["proof"]["tmp_name"],WP_CONTENT_DIR .'/uploads/'.basename($_FILES['proof']['name']));
$attachments = array(WP_CONTENT_DIR ."/uploads/".$_FILES["proof"]["name"]);
} else {
$proofOfFunds = "No";
}
$realEstateAgent = $_POST['realEstateAgent'];
$commission_rate = $_POST['commission_rate'];
$doYouNeedOne = $_POST['doYouNeedOne'];
if (isset($realEstateAgent) && $realEstateAgent == 1) {
$realEstateAgent = $commission_rate;
} else {
$realEstateAgent = $doYouNeedOne;
}
$closingPickAll = $_POST['closing'];
if (isset($closingPickAll) && count($closingPickAll) > 0) {
$closingPickAll = implode(',', $closingPickAll);
} else {
$closingPickAll = '';
}
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if (!preg_match($email_exp, $email)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if (!preg_match($string_exp, $first_name )) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if (strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string)
{
$bad = array("content-type", "bcc:", "to:", "cc:", "href");
return str_replace($bad, "", $string);
}
$email_message = "Hello Admin, You have got a new contact with following details: \n\n";
$email_message .= "First Name : " . clean_string($first_name) . "\n";
$email_message .= "Last Name : " . clean_string($last_name) . "\n";
$email_message .= "Email : " . clean_string($email) . "\n";
$email_message .= "Phone : " . clean_string($phone) . "\n";
$email_message .= "Address one : " . clean_string($addressOne) . "\n";
$email_message .= "Address two : " . clean_string($addressTwo) . "\n";
$email_message .= "Real estate interest : " . clean_string($realEstateInterest) . "\n";
$email_message .= "Purchase requirement : " . clean_string($purchaseReqirement) . "\n";
$email_message .= "Real estate agent : " . clean_string($realEstateAgent) . "\n";
$email_message .= "Close pick all : " . clean_string($closingPickAll) . "\n\n\n";
$email_message .="Thanks & Regards, \n" . $first_name ." ". $last_name ;
$headers = "From: ". $email . "\r\n";
$headers .= "Reply-To: " . $email . "\r\n";
$headers .= "X-Mailer: PHP/" . phpversion() ;
$headers .= "MIME-Version: 1.0" . "\r\n";
$mail = wp_mail($email_to, $email_subject , $email_message , $headers, $attachments);
echo $mail ? "Thank you for connecting with us! We will contact you shortly!" : " Mail failed";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment