After successful form validation, I want to display a popup successful message using fancybox plugin.
Here is my php code -
<?php
if(isset($_POST['cfsubmit'])){
//if no erros, echo the results
if(!$errorExists){
echo "<div id='c_confirm'><p><span class='check_mark'></span>Thank you for contacting With us. One of our customer service representatives will get back to you within 24 hours.</p></div>";
$emailTo = "myemail@gmail.com";
if (!isset($emailTo) || ($emailTo == '') ){
$emailTo = get_option('admin_email');
}
$subject = 'Contact Form from '.$fname;
$body = "First Name: $fname \n\nLast Name: $lname \n\nCheck In date: $check_in_date \n\nCheck Out date: $check_out_date \n\nApartment type: $apart_type \n\nPhone: $phone \n\nEmail: $email \n\nComments: $comments";
$headers = 'From: '.$fname.' <'.$email.'>' . "\r\n" . 'Reply-To: ' . $email . "\r\n";
wp_mail($emailTo, $subject, $body, $headers);
}else{
echo "<h3>Error!</h3>".$errors;
}
}?>
I want to display this message , in a popup box. Using jquery fancybox plugin.
<div id='c_confirm'><p><span class='check_mark'></span>Thank you for contacting With us. One of our customer service representatives will get back to you within 24 hours.</p></div>
Assuming that you have properly loaded jQuery and fancybox js and css files, your could do :
if(!$errorExists){
$fancymessage = "<div id='c_confirm'><p><span class='check_mark'></span>Thank you for contacting With us. One of our customer service representatives will get back to you within 24 hours.</p></div>";
?>
<script>
jQuery(document).ready(function($){
$.fancybox("<?php echo $fancymessage; ?>");
});
</script>
<?php
$emailTo = "myemail@gmail.com";
if (!isset($emailTo) || ($emailTo == '') ){
$emailTo = get_option('admin_email');
}
... etc.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.