I'm trying to make a page for people to submit what they with to receive from our company as seen here http://www.advantethinktank.com/tahoe2/Build/promotions
When the form is submitted, it always returns the error "please fill all forms" but I have filled all the forms. The php code is as follows.
'test@test.com', // Your Email Address
'name' => 'Promotions Page' // 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['template-contactform-email'] != '' ) {
$name = isset( $_POST['template-contactform-name'] ) ? $_POST['template-contactform-name'] : '';
$title = isset( $_POST['template-contactform-title'] ) ? $_POST['template-contactform-title'] : '';
$address1 = isset( $_POST['template-contactform-address1'] ) ? $_POST['template-contactform-address1'] : '';
$address2 = isset( $_POST['template-contactform-address2'] ) ? $_POST['template-contactform-address2'] : '';
$city = isset( $_POST['template-contactform-city'] ) ? $_POST['template-contactform-city'] : '';
$state = isset( $_POST['template-contactform-state'] ) ? $_POST['template-contactform-state'] : '';
$zip = isset( $_POST['template-contactform-zip'] ) ? $_POST['template-contactform-zip'] : '';
$howlong = isset( $_POST['template-contactform-howlong'] ) ? $_POST['template-contactform-howlong'] : '';
$products = isset( $_POST['template-contactform-products'] ) ? $_POST['template-contactform-products'] : '';
$message = isset( $_POST['template-contactform-message'] ) ? $_POST['template-contactform-message'] : '';
$subject = isset($subject) ? $subject : 'New Message From Promotions Form';
$botcheck = $_POST['template-contactform-botcheck'];
if( $botcheck == '' ) {
$mail->SetFrom( $email , $name );
$mail->AddReplyTo( $email , $name );
foreach( $toemails as $toemail ) {
$mail->AddAddress( $toemail['email'] , $toemail['name'] );
}
$mail->Subject = $subject;
$name = isset($name) ? "Name: $name
" : '';
$title = isset($title) ? "Title: $title
" : '';
$address1 = isset($address1) ? "Address: $address1
" : '';
$address2 = isset($address2) ? "Apt, Suite, Bldg.: $address2
" : '';
$city = isset($city) ? "City: $city
" : '';
$state = isset($state) ? "State: $state
" : '';
$zip = isset($zip) ? "Zip Code: $zip
" : '';
$howlong = isset($howlong) ? "How Long I've Been A Tahoe Enthusiast: $howlong
" : '';
$products = isset($products) ? "Products I'm Interested In: " . ( is_array($products) ? implode( ', ', $products ) : $products ) . "
" : '';
$message = isset($message) ? "Message: $message
" : '';
$referrer = $_SERVER['HTTP_REFERER'] ? '
This Form was submitted from: ' . $_SERVER['HTTP_REFERER'] : '';
$body = "$name $title $address1 $address2 $city $state $zip $howlong $products $message";
if( isset( $_FILES['template-contactform-file'] ) AND is_array( $_FILES['template-contactform-file'] ) ) {
$countfiles = count( $_FILES['template-contactform-file'] );
for( $i=0; $i IsHTML(true);
$mail->AddAttachment( $_FILES['template-contactform-file']['tmp_name'][$i], $_FILES['template-contactform-file']['name'][$i] );
}
}
}
// 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." }';
}
?>
What am I doing wrong?
