Contact form successfully sending but preloader keeps spinning!

3 replies · opened Jun 29, 2017

JjumatoJun 29, 2017

Hello SemiColonWeb,

I am having an issue with the contact form on this website:

http://www.aundb-group.de

The form works just fine. It sends out the email like it should
but somehow after hitting the send button the preloader appears
and stays until I refresh the browser window. No success message is shown either.

I disabled the recaptcha but no success on solving the issue.
When I move the site to a different server (it's the same provider and should be the same server settings)
it all works as expected.

Here's the link to the working contact form:

http://www.jumato.de/client/aundb/

It would be great if you could take a look at it.

Thanks.

JjumatoJun 29, 2017

` <div class="postcontent nobottommargin">
<div class="contact-widget">
<div class="contact-form-result"></div>
<form class="nobottommargin" id="template-contactform" name="template-contactform" method="post" action="include/sendemail.php">
<div class="form-process"></div>
<div class="col_one_third">
<label for="template-contactform-company">Firma </label>
<input type="text" id="template-contactform-company" name="template-contactform-company" value="" class="sm-form-control" />
</div>
<div class="col_one_third">
<label for="template-contactform-name">Vorname <small></small></label>
<input type="text" id="template-contactform-name" name="template-contactform-name" value="" class="required name sm-form-control" />
</div>
<div class="col_one_third col_last">
<label for="template-contactform-lastname">Nachname <small>
</small></label>
<input type="text" id="template-contactform-lastname" name="template-contactform-lastname" value="" class="required lastname sm-form-control" />
</div>
<div class="clear"></div>
<div class="col_half">
<label for="template-contactform-email">Email <small></small></label>
<input type="email" id="template-contactform-email" name="template-contactform-email" value="" class="required email sm-form-control" />
</div>
<div class="col_half col_last">
<label for="template-contactform-phone">Telefon <small>
</small></label>
<input type="text" id="template-contactform-phone" name="template-contactform-phone" value="" class="required phone sm-form-control" />
</div>
<div class="col_full">
<label for="template-contactform-subject">Betreff <small></small></label>
<input type="text" id="template-contactform-subject" name="template-contactform-subject" value="" class="required sm-form-control" />
</div>
<div class="clear"></div>
<div class="col_full">
<label for="template-contactform-message">Ihre Nachricht <small>
</small></label>
<textarea class="required sm-form-control" id="template-contactform-message" name="template-contactform-message" rows="6" cols="30"></textarea>
</div>
<div class="col_full">
<button class="button nomargin" type="submit" id="template-contactform-submit" name="template-contactform-submit" value="submit">Nachricht senden</button>
</div>
<div class="clear"></div>
<div class="col_full hidden">
<input type="text" id="template-contactform-botcheck" name="template-contactform-botcheck" value="" class="sm-form-control" />
</div>
<div class="col_full">
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<div class="g-recaptcha" data-sitekey="6LcxzyMUAAAAAKwxIhRvc_H-SgMudLPitRt_12Q8"></div>
</div>
</form>
</div>
</div>

JjumatoJun 29, 2017

And here is the sendemail file:

`<?php

require_once('phpmailer/PHPMailerAutoload.php');

$toemails = array();

$toemails[] = array(
'email' => 'tobi.ruettger@googlemail.com', // Your Email Address
'name' => 'A&B Group' // Your Name
);

// Form Processing Messages
$message_success = 'Vielen Dank. Wir haben ihre Nachricht erfolgreich erhalten.';

// Add this only if you use reCaptcha with your Contact Forms
$recaptcha_secret = '6LcxzyMUAAAAAL58bxqJv55jbZoyLn-162wMBUkt'; // 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'] != '' ) {

	$company = isset( $_POST['template-contactform-company'] ) ? $_POST['template-contactform-company'] : '';
	$name = isset( $_POST['template-contactform-name'] ) ? $_POST['template-contactform-name'] : '';
	$lastname = isset( $_POST['template-contactform-lastname'] ) ? $_POST['template-contactform-lastname'] : '';
	$email = isset( $_POST['template-contactform-email'] ) ? $_POST['template-contactform-email'] : '';
	$phone = isset( $_POST['template-contactform-phone'] ) ? $_POST['template-contactform-phone'] : '';
	$subject = isset( $_POST['template-contactform-subject'] ) ? $_POST['template-contactform-subject'] : '';
	$message = isset( $_POST['template-contactform-message'] ) ? $_POST['template-contactform-message'] : '';

	$subject = isset($subject) ? $subject : 'Neue Nachricht vom Kontaktformular';

	$botcheck = $_POST['template-contactform-botcheck'];

	if( $botcheck == '' ) {

		$mail-&gt;SetFrom( $email , $name );
		$mail-&gt;AddReplyTo( $email , $name );
		foreach( $toemails as $toemail ) {
			$mail-&gt;AddAddress( $toemail['email'] , $toemail['name'] );
		}
		$mail-&gt;Subject = $subject;

		$company = isset($company) ? "Firma: $company&lt;br&gt;&lt;br&gt;" : '';
		$name = isset($name) ? "Vorname: $name&lt;br&gt;&lt;br&gt;" : '';
		$lastname = isset($lastname) ? "Nachname: $lastname&lt;br&gt;&lt;br&gt;" : '';
		$email = isset($email) ? "Email: $email&lt;br&gt;&lt;br&gt;" : '';
		$phone = isset($phone) ? "Telefonnummer: $phone&lt;br&gt;&lt;br&gt;" : '';
		$subject = isset($subject) ? "Betreff: $subject&lt;br&gt;&lt;br&gt;" : '';
		$message = isset($message) ? "Nachricht: $message&lt;br&gt;&lt;br&gt;" : '';

		$referrer = $_SERVER['HTTP_REFERER'] ? '&lt;br&gt;&lt;br&gt;&lt;br&gt;This Form was submitted from: ' . $_SERVER['HTTP_REFERER'] : '';

		$body = "$company $name $lastname $email $phone $subject $message $referrer";

		// Runs only when File Field is present in the Contact Form
		if ( isset( $_FILES['template-contactform-file'] ) && $_FILES['template-contactform-file']['error'] == UPLOAD_ERR_OK ) {
			$mail-&gt;IsHTML(true);
			$mail-&gt;AddAttachment( $_FILES['template-contactform-file']['tmp_name'], $_FILES['template-contactform-file']['name'] );
		}

		// 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-&gt;success !== true ) {
				echo '{ "alert": "error", "message": "Bitte bestätigen Sie dass Sie kein Roboter sind." }';
				die;
			}
		}

		// Uncomment the following Lines of Code if you want to Force reCaptcha Validation

		// if( !isset( $_POST['g-recaptcha-response'] ) ) {
		// 	echo '{ "alert": "error", "message": "Captcha not Submitted! Please Try Again." }';
		// 	die;
		// }

		$mail-&gt;MsgHTML( $body );
		$mail-&gt;CharSet="UTF-8";
		$sendEmail = $mail-&gt;Send();

		if( $sendEmail == true ):
			echo '{ "alert": "success", "message": "' . $message_success . '" }';
		else:
			echo '{ "alert": "error", "message": "Ihre Nachricht konnte auf Grund eines **Fehlers** nicht gesendet werden. Bitte versuchen Sie es später noch einmal.&lt;br /&gt;&lt;br /&gt;**Reason:**&lt;br /&gt;' . $mail-&gt;ErrorInfo . '" }';
		endif;
	} else {
		echo '{ "alert": "error", "message": "Bot **Detected**.! Clean yourself Botster.!" }';
	}
} else {
	echo '{ "alert": "error", "message": "Bitte **füllen Sie alle Pflichtfelder aus**." }';
}

} else {
echo '{ "alert": "error", "message": "Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut." }';
}

?>

SSemicolon WebSTAFFJul 3, 2017

Hello,

We have just checked out your Website and the Contact Form appears to be displaying an Error Notification for your Form, possibly because of an Issue with the reCaptcha API Keys. Please consider fixing this error according the Error Message displayed and the issue should be resolved automatically.

Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard