'; //Thanks to Frequency Decoder for the Date Picker Script. http://www.frequency-decoder.com } function CleanStringRomeLuvBookingForm($content) {return wp_kses($content,'');} function sbf_rl_widget() { echo romeluv_booking_form(''); } register_sidebar_widget("Simple Booking Form", "sbf_rl_widget"); add_shortcode('BOOKINGFORM', 'romeluv_booking_form'); function romeluv_booking_form($atts) { $out.=''; global $_POST; global $post; $FormErrors=FALSE; ///VALIDAZIONE FORM, se c' if ($_POST['submit-enquiry']) { //validazione caso submit step 2 $number_of_guests=CleanStringRomeLuvBookingForm($_POST['number_of_guests']); $contactemail=CleanStringRomeLuvBookingForm($_POST['contactemail']); $contactname=CleanStringRomeLuvBookingForm($_POST['contactname']); $telephone=CleanStringRomeLuvBookingForm($_POST['telephone']); $notes=CleanStringRomeLuvBookingForm($_POST['notes']); $random_value= CleanStringRomeLuvBookingForm($_POST['random_value']); $controlusercheck= $_POST[controlusercheck]; $arrivaldate=CleanStringRomeLuvBookingForm($_POST[arrivaldate]); $departuredate =CleanStringRomeLuvBookingForm($_POST[departuredate]); $number_of_guests=CleanStringRomeLuvBookingForm($_POST['number_of_guests']); //add sicurezza //valido errori if ($contactname=="") $FormErrors.="

Please fill in the Name field.

"; if ( !is_email($contactemail)) $FormErrors.="

Please fill in the Email field with a proper email.

"; if (($number_of_guests=='') ) $FormErrors.="

Please enter the number of guests.

"; if (($telephone=='') ) $FormErrors.="

Please enter your phone number.

"; if (($arrivaldate=='') ) $FormErrors.="

Please enter your arrival date.

"; if (($departuredate=='') ) $FormErrors.="

Please enter your departure date.

"; if (($controlusercheck!=$random_value+2) ) $FormErrors.="

Please answer correctly to the Anti-Spam question.

"; } /////MODULO: STEP 1 if (!$_POST OR ($FormErrors&& $_POST['submit-enquiry'] ) ) { $random_value=rand(0,10); $out.='

Send an enquiry

(ALL fields required)
Your dates

No Guests
Full name
Email
Mobile #
2+'.$random_value.' = (Anti-spam question)
Notes (Optional)
'; $out.= '
'.$FormErrors."
"; $out.='
Booking Form By RomeLuv
'; } global $_POST; ////STEP 2: CONFERMA e manda mail if ($_POST['submit-enquiry']&& !$FormErrors) { $out.='

Dear '. $contactname.', Thank you for you enquiry.

We will reply to you as soon as possible.

Your enquiry:
'.get_the_title($post->ID).' - Accommodation ID: '.$post->ID.'
Arrival date: '.$arrivaldate.'    
Departure date: '.$departuredate.'    
No Guests: '.$number_of_guests .'
Name: '.$_POST['contactname'].'
Email: '.$_POST['contactemail'].'
Mobile Number: ' .$_POST['telephone'].'
Notes: '.$_POST['notes'].'
'; $email_html = $out; $post_name=get_the_title($post->ID); $permalink = get_permalink($post->ID); $permalink=substr($permalink,7); //levo Http:// $now=date("Y-m-d H:i:s",time()); //data e ora attuale global $_SERVER; $ipaddress=$_SERVER['REMOTE_ADDR']; //send email $oggetto .= "Booking request from ". $contactname." | ".get_the_title(); $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'From: '.get_option('blogname').' <'.get_option('admin_email').'> '; // Mail it mail($contactemail, $oggetto, $email_html, $headers); mail(get_option('admin_email'), $oggetto, $email_html, $headers); $out.='
'; } return $out; } //end romeluv booking form function ?>