HI
I looked at the link and followed the logic very closely but the form still fails.
Could you look and check this please?
Hi
I have followed your logic above very closely but i still get the issue of 'please fill out all the details':
Form Fields are:
<form class="nobottommargin" id="template-contactform" name="template-contactform" action="../include/sendemail-viewing.php" method="post"> <div class="contact-form-result">
<input name="Form-Subject" type="hidden" id="Form-Subject" value="Viewing-Request">
</div><div class="contact-widget"><div class="col_full"><h4 class="color"> Wedding / Civil Partnership Details</h4>
<div class="form-process"></div>
<div class="col_one_fourth">
<label for="Bride / Partner Name">Bride/Partner Name <small>*</small></label>
<input name="Bride-Partner-Name" type="text" required class="sm-form-control required" id="Bride-Partner-Name" value="" />
</div><div class="col_one_fourth">
<label for="Bride-Partner Name">Groom/Partner Name <small>*</small></label>
<input name="Groom-Partner-Name" type="text" required class="sm-form-control required" id="Groom-Partner-Name" value="" />
</div>
<div class="col_one_fourth">
<label for="">Preferred Wedding Date </label>
<input name="Preferred-Wedding-Date" type="text" class="sm-form-control tleft format date-picker" id="Preferred-Wedding-Date" placeholder="DD-MM-YYYY" value="">
</div>
<div class="col_one_fourth col_last"> <label>Wedding Type<small>*<br>
</small></label>
<select name="Wedding-Type" id="Wedding-Type" class="sm-form-control required">
<option selected="selected">Select</option>
<option value="Church-Wedding">Church Wedding</option>
<option value="Civil-Ceremony">Civil Ceremony</option>
</select>
</div></div>
<div class="divider divider-center"><i class="icon-heart"></i></div>
<div class="col-full"><h4 class="color"> Guest Numbers</h4>
<div class="col_one_fourth"> <label>Day - (Min of 60)<small>*<br>
</small></label>
<input type="text" id="Day-Guests" name="Day-Guests" value="" class="required sm-form-control" />
</div> <div class="col_one_fourth">
<label>Day - Under 2 Yrs<small>*<br>
</small></label>
<input type="text" id="Day-Guests-Under-2" name="Day-Guests-Under-2" value="" class="required sm-form-control" />
</div>
<div class="col_one_fourth">
<label>Day - Between 2 & 10 Yrs<small>*<br>
</small></label>
<input type="text" id="Day-Between-2-10-Yrs" name="Day-Between-2-10-Yrs" value="" class="required sm-form-control" />
</div> <div class="col_one_fourth col_last"> <label>Evening (Minimum of 100)<small>*<br>
</small></label>
<input type="text" id="Evening-Guests" name="Evening-Guests" value="" class="required sm-form-control" />
</div>
<div class="divider divider-center"><i class="icon-heart"></i></div>
<div class="col-full">
<h4 class="color"> Address Details</h4>
<div id="locationField">
<input id="autocomplete" placeholder="Start typing your address"
onFocus="geolocate()" type="text" class=" sm-form-control"></input>
</div>
<div id="address"> <div class="col_one_fourth"> <label>House Name/Number<small><br>
</small></label>
<input name="House-Name-Number" disabled="true" class="required sm-form-control"id="street_number" placeholder="House Number">
</div> <div class="col_one_fourth">
<label>Address Line 1<small><br>
</small></label>
<input name="Address-Line-1" disabled="true" class="required sm-form-control" id="route">
</div>
<div class="col_one_fourth">
<label>Address LIne 2<small><br>
</small></label>
<input name="Address-Line-2"
disabled="true" class="required sm-form-control" id="locality">
</div> <div class="col_one_fourth col_last"> <label>Post Code<small><br>
</small></label>
<input name="Post-Code" disabled="true" class="required sm-form-control" id="postal_code"></input>
</div>
<div class="divider divider-center"><i class="icon-heart"></i></div></div>
<table id="address" class="hidden">
<tr>
<td class="wideField" colspan="2"></td>
</tr>
<tr>
<td class="label">State</td>
<td class="slimField"><input class="field"
id="administrative_area_level_1" disabled="true"></input></td>
<td class="label">Post Code</td>
<td class="wideField"><input class="field" id="postal_code"
disabled="true"></input></td>
</tr>
<tr>
<td class="label">Country</td>
<td class="wideField" colspan="3"><input class="hidden"
id="country" disabled="true"></input></td>
</tr>
</table>
<div class="col-full">
<h4 class="color"> Contact Details</h4>
<div class="col_one_fourth"> <label>Bride/Partner Phone<small><br>
</small></label>
<input type="text" id="Bride-Partner-Phone" name="Bride-Partner-Phone" value="" class="required sm-form-control" />
</div> <div class="col_one_fourth">
<label>Bride/Partner Email<small><br>
</small></label>
<input type="text" id="Bride-Partner-Email" name="Bride-Partner-Email" value="" class="required sm-form-control" />
</div>
<div class="col_one_fourth">
<label>Groom/Partner Phone<small><br>
</small></label>
<input type="text" id="Groom-Partner-Phone" name="Groom-Partner-Phone" value="" class="required sm-form-control" />
</div> <div class="col_one_fourth col_last"> <label>Groom/Partner Email<small><br>
</small></label>
<input type="text" id="Groom-Partner-Email" name="Groom-Partner-Email" value="" class="required sm-form-control" />
</div>
<div class="divider divider-center"><i class="icon-heart"></i></div>
<div class="col-full">
<h4 class="color"> Viewing Details</h4>
<div class="col_one_fourth"> <label>Preferred Date/Time<small><br>
</small></label>
<input name="Preferred-Date-Time" type="text" class="tleft sm-form-control datetimepicker" id="Preferred-Date-Time" placeholder="DD/MM/YYYY 00:00 AM/PM"/>
</div> <div class="col_one_fourth">
<label>Number of visitors (max of 4)<small><br>
</small></label>
<input type="text" id="Number-Visitors" name="Number-Visitors" value="" class="required sm-form-control" />
</div><div class="col_half col_last">
<label>Brief Comments<small><br>
</small></label>
<input type="text" id="Comments" name="Comments" value="" class="required sm-form-control" />
</div><br clear="all">
<div class="divider divider-center"><i class="icon-heart"></i></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="6LekGhkUAAAAAJu3AVIdCrH4sh6f-gEt0J0qhbow"></div>
</div>
<div class="col_full">
<button class="button button-3d " type="submit" id="template-contactform-submit" name="template-contactform-submit" value="submit">Send Viewing Request</button>
</div>
<p> </p>
<p></p>
</div></div></form>
Sendmail Script is here:
// 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 = '6LekGhkUAAAAAC2jXWGMptyg4JDpiOK77F6-Q-zi'; // 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'] != '' ) {
$subject = isset( $_POST['Form-Subject'] ) ? $_POST['Form-Subject'] : '';
$name1 = isset( $_POST['Bride-Partner-Name'] ) ? $_POST['Bride-Partner-Name'] : '';
$name2 = isset( $_POST['Groom-Partner-Name'] ) ? $_POST['Groom-Partner-Name'] : '';
$weddingdate = isset( $_POST['Preferred-Wedding-Date'] ) ? $_POST['Preferred-Wedding-Date'] : '';
$weddingtype = isset( $_POST['Wedding-Type'] ) ? $_POST['Wedding-Type'] : '';
$dayguests = isset( $_POST['Day-Guests'] ) ? $_POST['Day-Guests'] : '';
$dayguestsunder2 = isset( $_POST['Day-Guests-Under-2'] ) ? $_POST['Day-Guests-Under-2'] : '';
$dayguest2to10 = isset( $_POST['Day-Between-2-10-Yrs'] ) ? $_POST['Day-Between-2-10-Yrs'] : '';
$eveningguests = isset( $_POST['Evening-Guests'] ) ? $_POST['Evening-Guests'] : '';
$housenumber = isset( $_POST['House-Name-Number'] ) ? $_POST['House-Name-Number'] : '';
$addressline1 = isset( $_POST['Address-Line-1'] ) ? $_POST['Address-Line-1'] : '';
$addressline2 = isset( $_POST['Address-Line-2'] ) ? $_POST['Address-Line-2'] : '';
$postcode= isset( $_POST['Post-Code'] ) ? $_POST['Post-Code'] : '';
$bridephone = isset( $_POST['Bride-Partner-Phone'] ) ? $_POST['Bride-Partner-Phone'] : '';
$email = isset( $_POST['Bride-Partner-Email'] ) ? $_POST['Bride-Partner-Email'] : '';
$groomphone = isset( $_POST['Groom-Partner-Phone'] ) ? $_POST['Groom-Partner-Phone'] : '';
$visit = isset( $_POST['Preferred-Date-Time'] ) ? $_POST['Preferred-Date-Time'] : '';
$visitors = isset( $_POST['Number-Visitors'] ) ? $_POST['Number-Visitors'] : '';
$comments = isset( $_POST['Comments'] ) ? $_POST['Comments'] : '';
$message = isset( $_POST['template-contactform-message'] ) ? $_POST['template-contactform-message'] : '';
$subject = isset($subject) ? $subject : 'New Viewing Request';
$botcheck = $_POST['template-contactform-botcheck'];
if( $botcheck == '' ) {
$mail->SetFrom( $email , $name1 );
$mail->AddReplyTo( $email , $name1 );
foreach( $toemails as $toemail ) {
$mail->AddAddress( $toemail['email'] , $toemail['name1'] );
}
$mail->Subject = $subject;
$name1 = isset($name1) ? "Bride/Partner Name: $name1<br><br>" : '';
$name2 = isset($nam1e) ? "Groomm/Partner Name: $name2<br><br>" : '';
$weddingdate = isset($weddingdate) ? "Preferred Wedding Date: $weddingdate<br><br>" : '';
$weddingtype = isset($weddingtype) ? "Wedding Type: $weddingtype <br><br>" : '';
$dayguests = isset($dayguests) ? "Number of Day Guests: $dayguests <br><br>" : '';
$dayguestsunder2 = isset($dayguestsunder2) ? "Number of Day Guests Under 2 Years Old: $dayguestsunder2<br><br>" : '';
$dayguest2to10 = isset($dayguest2to10) ? "Number of Day Guests Between 2 and 10 Years Old: $dayguest2to10<br><br>" : '';
$eveningguests = isset($eveningguests) ? "Number of Evening Guests: $eveningguests <br><br>" : '';
$housenumber = isset($housenumber) ? "House Number: $housenumber <br><br>" : '';
$addressline1 = isset($addressline1) ? "Address Line 1: $addressline1 <br><br>" : '';
$addressline2 = isset($addressline2 ) ? "Address Line 2: $addressline2 <br><br>" : '';
$postcode = isset($postcode) ? "Post Code: $postcode <br><br>" : '';
$bridephone = isset($bridephone) ? "Bride/Partner Telephone: $bridephone <br><br>" : '';
$email = isset($email) ? "Bride/Partner Email: $email<br><br>" : '';
$groomphone = isset($groomphone) ? "Groom/Partner Phone: $groomphone<br><br>" : '';
$visit = isset($visit ) ? "Preferred Visit Date and Time: $visit <br><br>" : '';
$visitors = isset($visitors ) ? "Number of Visitors: $visitors <br><br>" : '';
$comments = isset($comments) ? "Comments: $comments<br><br>" : '';
$referrer = $_SERVER['HTTP_REFERER'] ? '<br><br><br>IP address the form was submitted from: ' . $_SERVER['HTTP_REFERER'] : '';
$body = "$name1, $name2, $weddingdate, weddingtype, $dayguest, $dayguestsunder2, $dayguestsunder2, $dayguest2to10, $eveningguests, $housenumber, $addressline1, $addressline2, $postcode, $bridephone, $email, $groomphone, $visit, $visitors, $comments, $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->IsHTML(true);
$mail->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->success !== true ) {
echo '{ "alert": "error", "message": "Captcha not Validated! Please Try Again." }';
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->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.<br /><br />**Reason:**<br />' . $mail->ErrorInfo . '" }';
endif;
} else {
echo '{ "alert": "error", "message": "Bot **Detected**.! Clean yourself Botster.!" }';
}
} else {
echo '{ "alert": "error", "message": "Looks like you missed something. Please check all the fields and try again." }';
}
} else {
echo '{ "alert": "error", "message": "An unexpected error occured. Please try again later." }';
}
?>Please try again later." }';