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:
Send Us An Email
First name *
Last name *
Company *
Title *
Email *
Phone *
Please briefly describe your marketing goals for Nimblefish products:
[Close](#)
Send Message
PHP:
'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 **successfully** 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 **could not** be sent due to some Unexpected Error. Please Try Again later.
**Reason:**
' . $mail->ErrorInfo . '" }';
endif;
} else {
echo '{ "alert": "error", "message": "Bot **Detected**.! Clean yourself Botster.!" }';
}
} else {
echo '{ "alert": "error", "message": "Please **Fill up** all the Fields and Try Again." }';
}
} else {
echo '{ "alert": "error", "message": "An **unexpected error** occured. Please Try Again later." }';
}
?>
