Hello,
Before I get into my main question, I was wondering if there is any possibility of integrating the contact form with Eloqua and having server side validation? Is this possible?
Main problem: I am building a company website that requires a contact form. I followed the instructions in the documentation but it's not working so I don't know how to set it up correctly. I added more fields (changed name to first name, added last name, company, title, phone).
Here is the website (in QA): corp.nimblefish.com/newsite
HTML:
<div data-target="#myModal1"></div>
<!-- Modal -->
<div class="modal1 mfp-hide" id="myModal1">
<div class="block divcenter" style="background-color: #FFF; max-width: 600px;">
<div style="padding: 50px;">
<div class="fancy-title title-dotted-border">
<h3>Send Us An Email</h3>
</div>
<div class="widget quick-contact-widget clearfix">
<div class="quick-contact-form-result"></div>
<form id="quick-contact-form" name="quick-contact-form" action="include/quickcontact.php" method="post" class="quick-contact-form nobottommargin">
<div class="form-process"></div>
<div class="col_half">
<label for="firstName">First name <small>*</small></label>
<input type="text" class="required form-control input-block-level" id="firstName" name="firstName" value="" />
</div>
<div class="col_half col_last">
<label for="lastName">Last name <small>*</small></label>
<input type="text" class="required form-control input-block-level" id="lastName" name="lastName" value="" />
</div>
<div class="clear"></div>
<div class="col_full">
<label for="company">Company <small>*</small></label>
<input type="text" class="required form-control input-block-level" id="company" name="company" value="" />
</div>
<div class="clear"></div>
<div class="col_full">
<label for="title">Title <small>*</small></label>
<input type="text" class="required form-control input-block-level" id="title" name="title" value="" />
</div>
<div class="clear"></div>
<div class="col_full">
<label for="emailAddress">Email <small>*</small></label>
<input type="email" class="required form-control input-block-level" id="emailAddress" name="emailAddress" value="" />
</div>
<div class="clear"></div>
<div class="col_full">
<label for="busPhone">Phone <small>*</small></label>
<input type="text" class="required form-control input-block-level" id="busPhone" name="busPhone" value="" />
</div>
<div class="clear"></div>
<div class="col_full">
<label for="comments1">Please briefly describe your marketing goals for Nimblefish products:</label>
<textarea class="form-control input-block-level short-textarea" id="comments1" name="comments1" rows="6" cols="30"></textarea>
</div>
<div class="col_full hidden">
<input type="text" class="hidden" id="quick-contact-form-botcheck" name="quick-contact-form-botcheck" value="" />
</div>
<div class="col_full" style="text-align:right;">
<a href="#" class="button button-3d nomargin" onClick="$.magnificPopup.close();return false;">Close</a>
<button class="button button-3d nomargin" type="submit" id="submit" name="submit" value="submit">Send Message</button>
</div>
</form>
</div>
</div>
</div>PHP:
<?php
require_once('phpmailer/PHPMailerAutoload.php');
$toemails = array();
$toemails[] = array(
'email' => 'francis.ngo@rrd.com', // Your Email Address
'name' => 'Francis' // Your Name
);
// $toemails[] = array(
// 'email' => 'username@website.com', // Your Email Address
// 'name' => 'Your Name' // Your Name
// );
//
// $toemails[] = array(
// 'email' => 'username@website.com', // Your Email Address
// 'name' => 'Your Name' // Your Name
// );
// Form Processing Messages
$message_success = 'We have <strong>successfully</strong> received your Message and will get Back to you as soon as possible.';
// Add this only if you use reCaptcha with your Contact Forms
$recaptcha_secret = ''; // Your reCaptcha Secret
$mail = new PHPMailer();
// If you intend you use SMTP, add your SMTP Code after this Line
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
if( $_POST['emailAddress'] != '' ) {
$fname = $_POST['firstName'];
$lname = $_POST['lastName'];
$company = $_POST['company'];
$title = $_POST['title'];
$email = $_POST['emailAddress'];
$phone = $_POST['busPhone'];
$message = $_POST['comments1'];
$subject = 'New Message From Nimblefish Contact Form';
$botcheck = $_POST['quick-contact-form-botcheck'];
if( $botcheck == '' ) {
$mail->SetFrom( $email , $name );
$mail->AddReplyTo( $email , $name );
foreach( $toemails as $toemail ) {
$mail->AddAddress( $toemail['email'] , $toemail['name'] );
}
$mail->Subject = $subject;
$fname = isset($fname) ? "First Name: $fname
" : '';
$lname = isset($lname) ? "Last Name: $lname
" : '';
$company = isset($company) ? "Company: $company
" : '';
$title = isset($title) ? "Title: $title
" : '';
$email = isset($email) ? "Email: $email
" : '';
$phone = isset($phone) ? "Phone: $phone
" : '';
$message = isset($message) ? "Comments: $message
" : '';
$referrer = $_SERVER['HTTP_REFERER'] ? '
This Form was submitted from: ' . $_SERVER['HTTP_REFERER'] : '';
$body = "$fname $lname $compnay $title $email $phone $message $referrer";
// Runs only when reCaptcha is present in the Contact Form
if( isset( $_POST['g-recaptcha-response'] ) ) {
$recaptcha_response = $_POST['g-recaptcha-response'];
$response = file_get_contents( "https://www.google.com/recaptcha/api/siteverify?secret=" . $recaptcha_secret . "&response=" . $recaptcha_response );
$g_response = json_decode( $response );
if ( $g_response->success !== true ) {
echo '{ "alert": "error", "message": "Captcha not Validated! Please Try Again." }';
die;
}
}
$mail->MsgHTML( $body );
$sendEmail = $mail->Send();
if( $sendEmail == true ):
echo '{ "alert": "success", "message": "' . $message_success . '" }';
else:
echo '{ "alert": "error", "message": "Email <strong>could not</strong> be sent due to some Unexpected Error. Please Try Again later.
<strong>Reason:</strong>
' . $mail->ErrorInfo . '" }';
endif;
} else {
echo '{ "alert": "error", "message": "Bot <strong>Detected</strong>.! Clean yourself Botster.!" }';
}
} else {
echo '{ "alert": "error", "message": "Please <strong>Fill up</strong> all the Fields and Try Again." }';
}
} else {
echo '{ "alert": "error", "message": "An <strong>unexpected error</strong> occured. Please Try Again later." }';
}
?>