Blank mails from the Registration Form

html

#1

Hi,
I am getting blank mails everyday from the Registration form.
Please help me to, find out where I went wrong?
Here is the code:

HTML:


         <div class="reservation">
            <form name="wittysparks" id="ws" method="post" action="reservations.php" onsubmit="return get_action();">
               <div class="divform ver2">
                  <div class="r">
                     <div class="c">
                        <label for="Firstname"><span style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#333;">Room Type* :</span></label>
                     </div>
                     <div class="c">
                        
                        <select name="room" style="height:30px;" class="form" id="select" required  onChange="change_price(this.form.room)">
                           <option value="">Select Room Type</option>
                           <option value="Cottages - Regular Rooms">Cottages - Regular Rooms</option>
                           <option value="Cottages - Deluxe Rooms">Cottages - Deluxe Rooms</option>
                           <option value="Cottages - Family Room">Cottages - Family Room</option>
                           >
                           <option value="Villa with 3 Rooms">Villa with 3 Rooms</option>
                           <option value="Villa Singlets">Villa Singlets</option>
                           <option value="Villa Singlet Family">Villa Singlet Family</option>
                        </select>
                     </div>
                  </div>
                  <div class="r">
                     <div class="c">
                        <label for="Firstname"><span style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#333;"> Price :</span></label>
                     </div>
                     <div class="c">
                        <input type="text" name="price" id="price" value="" readonly style="font-size: 12px;"/>
                     </div>
                  </div>
                  <script>
                     function change_price(dropdown) {
                     //alert("dfs");
                     var myindex  = dropdown.selectedIndex;
                     var SelValue = dropdown.options[myindex].value;
                     var selbox=document.getElementById('price').value;
                     //alert(selbox);
                     //alert(SelValue);
                     
                     if (SelValue == "") {
                     document.getElementById('price').value="Select Room Type";
                     }
                     if (SelValue == "Cottages - Regular Rooms") {
                     //alert("dfs");
                     document.getElementById('price').value=" Price : Rs.1500*  ( 2 Adults + 1 Child ) ";
                     }
                     if (SelValue == "Cottages - Deluxe Rooms") {
                     document.getElementById('price').value=" Price : Rs.2200* ( 3 Adults +  1 Child ) ";
                     }
                     if (SelValue == "Cottages - Family Room") {
                     document.getElementById('price').value=" Price : Rs.3300*  ( 5 Adults  +  1 Child ) ";
                     }
                     if (SelValue == "Villa with 3 Rooms") {
                     document.getElementById('price').value=" Price Per Room  : Rs.3300*   ( 2 Adults + 1 Child )  ";
                     }
                     if (SelValue == "Villa Singlets") {
                     document.getElementById('price').value=" Price : Rs.3300*  ( 3 Adults  +  1 Child ) ";
                     }
                     if (SelValue == "Villa Singlet Family") {
                     document.getElementById('price').value=" Price : Rs.5500*  ( 5 Adults  +  1 Child ) ";
                     }
                     }
                  </script>
                  <div class="r" style="display: none;">
                     <div class="c">
                        <label for="Food Required"><span style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#333;">Food Required<img src="images/Extra.png" width="10" height="10"> :</span></label>
                     </div>
                     <div class="c">
                        <label for="Food">
                        <input type="radio"  name="Food"  id="Food" value="Yes"  />
                        <span style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#333;">Yes.</span></label>
                        <label for="Food">
                        <input type="radio" name="Food" id="Food" value="No" checked/>
                        <span style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#333;">No.</span></label>
                     </div>
                  </div>
                  <div class="r">
                     <div class="c">
                        <label for="duration"><span style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#333;"> Duration In Days:</span></label>
                     </div>
                     <div class="c">
                        <select name="duration" required id="duration" style="width: 200px; height:30px;">
                           <option selected="selected">Select No. of Days</option>
                           <option value="1">1</option>
                           <option value="2">2</option>
                           <option value="3">3</option>
                           
                        </select>
                     </div>
                  </div>
                  <div class="r">
                     <div class="c">
                        <label for="CheckIn"><span style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#333;">Check In Date & Time*:</span></label>
                     </div>
                     <div class="c">
                        <table width="220" border="0">
                           <tr>
                              <td>
                                 <input type="text" id="datepicker" name="datepicker" required>
                              </td>
                              <td>
                                 <select name="CheckIn" id="CheckIn" style="height:30px; width:80px;" required>
                                    <option value="">Time</option>
                                    <option value="5:00 AM">5:00 AM</option>
                                    <option value="5:15 AM">5:15 AM</option>
                                    <option value="5:30 AM">5:30 AM</option>
                                    <option value="5:45 AM">5:45 AM</option>
                                    <option value="6:00 AM">6:00 AM</option>
                                    <option value="6:15 AM">6:15 AM</option>
                                    <option value="6:30 AM">6:30 AM</option>
                                    <option value="6:45 AM">6:45 AM</option>
                                    
                                 </select>
                              </td>
                           </tr>
                        </table>
                     </div>
                  </div>
                  <div class="r">
                     <div class="c">
                        <label for="Checkout"><span style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#333;"> Check Out Date & Time*:</span></label>
                     </div>
                     <div class="c">
                        <table width="220" border="0">
                           <tr>
                              <td>
                                 <input type="text" id="datepicker2" name="datepicker2"size="30" required>
                              </td>
                              <td>
                                 <select name="Checkout" id="Checkout" style="height:30px; width:80px;" required>
                                    <option value="">Time</option>
                                    <option value="5:00 AM">5:00 AM</option>
                                    <option value="5:15 AM">5:15 AM</option>
                                    <option value="5:30 AM">5:30 AM</option>
                                    <option value="5:45 AM">5:45 AM</option>
                                    <option value="6:00 AM">6:00 AM</option>
                                    
                                 </select>
                              </td>
                           </tr>
                        </table>
                     </div>
                  </div>
                  <p>&nbsp;
                  </p>
                  <h1>Guest Details</h1>
                  <div class="r">
                     <div class="c">
                        <label for="Firstname"><span style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#333;">Name* :</span></label>
                     </div>
                     <div class="c">
                        <input type="text" id="Firstname" name="Firstname" value=""  required/>
                     </div>
                  </div>
                  <div class="r">
                     <div class="c">
                        <label for="Email ID"><span style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#333;">Email ID* :</span></label>
                     </div>
                     <div class="c">
                        <input type="email" id="EmailID" name="EmailID"  style="width:203px; height:20px; margin-left:5px;"value="" required/>
                     </div>
                  </div>
                  <div class="r">
                     <div class="c">
                        <label for="Address"><span style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#333;">Address* :</span></label>
                     </div>
                     <div class="c">
                        <input type="text" id="Address" name="Address" value="" required/>
                     </div>
                  </div>
                  <div class="r">
                     <div class="c">
                        <label for="Mobile No"><span style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#333;">Mobile No*	:</span></label>
                     </div>
                     <div class="c">
                        <input type="number" id="MobileNo" name="MobileNo" value=""  style="margin-left:8px; height:20px; width:200px;" required/>
                     </div>
                  </div>
                  <div class="r">
                     <div class="c">
                        <label for="PhoneNo"><span style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#333;">Phone No	:</span></label>
                     </div>
                     <div class="c">
                        <input type="text" id="PhoneNo" name="PhoneNo" value=""/>
                     </div>
                  </div>
                  <div class="r">
                     <div class="c">
                        <label for="Firstname"><span style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#333;">Comments	:</span></label>
                     </div>
                     <div class="c">
                        <textarea name="Message" id="Message" cols="22" wrap="physical" rows="3" value=""></textarea>
                     </div>
                  </div>
                  <div class="r">
                     <div class="c">
                        &nbsp;
                     </div>
                     <div class="r">
                        <div class="c">
                           <div class="form-group">
                              <div class="g-recaptcha" data-sitekey="xxxxxxxxxxxxxxxxxxxxxxxxxxxx" data-callback="correctCaptcha" data-expired-callback="expiredRecaptchaCallback"></div>
                              <span id="captcha" style="margin-left:100px;color:red" />
                           </div>
                        </div>
                     </div>
                     <div class="r">
                        <div class="c">
                           <input type="reset" name="button" value="Reset" />
                           &nbsp;&nbsp;
                           <input type="submit" name="submit_email" id="submit_email" value="Submit" />
                           
                        </div>
                     </div>
                     <br>
                     <br>
                     <br>
                  </div>
                  <br>
                  <br>
            </form>
            </div>
            <p>
               <img src="images/arrow.jpg"><span style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#c50c12;">* Including GST  </span>
               <br>
               <br>
               <img src="images/arrow.jpg"><span style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#c50c12;">Please Check Room Availability and Obtain Confirmation Over Phone</span>
               <br>
               <br>
               
               <img src="images/arrow.jpg"><span style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#c50c12;">Guests are requested to furnish a photo Id as per Government regulations before Checking In</span>
               <br>
               <br>
            </p>
            <link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
            <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
            <!-- Javascript -->
            <script>
               $(function() {
               $( "#datepicker" ).datepicker({
                dateFormat: "dd-mm-yy"
               });
                
               $( "#datepicker2" ).datepicker({
                dateFormat: "dd-mm-yy"
               });
               });
               
               
               
            </script>
         </div>
         
         

PHP code:

<?php
   //echo "<pre>";print_r($_POST); echo "</pre>";
   if($_POST['submit_email'] == "Submit") {
   $room			=	$_POST['room'];
   $price			=	$_POST['price'];
   $Food			=	$_POST['Food'];
   $duration		=	$_POST['duration'];
   $DateIn			=	$_POST['datepicker'];
   $CheckIn		=	$_POST['CheckIn'];
   $Dateout		=	$_POST['datepicker2'];
   $Checkout		=	$_POST['Checkout'];
   $Firstname		=	$_POST['Firstname'];
   $EmailID		=	$_POST['EmailID'];
   $Address		=	$_POST['Address'];
   $MobileNo		=	$_POST['MobileNo'];
   $PhoneNo		=	$_POST['PhoneNo'];
   $comment		=	$_POST['Message'];
   }
   
  
   $to='bookings@example.com,example@gmail.com';
   $subject = "Reservation Details"; 	
   $from = $EmailID;
   		
   $message ='<table width="800px" style="border:1px solid #FF9900;background-color:#ffe0d1; align="center" border="0" cellspacing="0"  cellpadding="0">
   <tr style="background-color:#65041b; color:#FFFFFF; font-family:Arial, Helvetica, sans-serif; font-size:18px; height:30px; "><th width="50%"  colspan="2">Enquiry</th></tr>
   
   
   <tr style="color:#000; font-family:Arial, Helvetica, sans-serif; font-size:12px; height:30px;"><th width="50%" style="text-align:left;" >&nbsp;Room</th><th width="50%" style="text-align:left;">'.$room.'</th></tr>
   
   <tr style="background-color:#d29272; color:#000; font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; height:30px;"><th width="50%" style="text-align:left;">&nbsp;Price (Rs.)</th><th width="50%"style="text-align:left;">'.$price.'</th></tr>
   
   
   <tr style="color:#000; font-family:Arial, Helvetica, sans-serif; font-size:12px; height:30px; text-align:left;display:none;"><th width="50%"style="text-align:left;">&nbsp;Food</th><th width="50%"style="text-align:left;">'.$Food.'</th></tr>
   
   <tr style="background-color:#d29272; color:#000; font-family:Arial, Helvetica, sans-serif; font-size:12px; height:30px; text-align:left;"><th width="50%"style="text-align:left;">&nbsp;Duration</th><th width="50%"style="text-align:left;">'.$duration.'</th></tr>
   
   
   <tr style="color:#000; font-family:Arial, Helvetica, sans-serif; font-size:12px; height:30px; text-align:left;"><th width="50%"style="text-align:left;">&nbsp;CheckIn</th><th width="50%"style="text-align:left;">'.$DateIn.' '.$CheckIn.'</th></tr>
   
   <tr style="background-color:#d29272;color:#000; font-family:Arial, Helvetica, sans-serif; font-size:12px; height:30px; text-align:left;"><th width="50%"style="text-align:left;">&nbsp;Checkout</th><th width="50%"style="text-align:left;">'.$Dateout.' '.$Checkout.'</th></tr>
   
   <tr style="color:#000; font-family:Arial, Helvetica, sans-serif; font-size:12px; height:30px; text-align:left;"><th width="50%" style="text-align:left;">&nbsp;Firstname</th><th width="50%"style="text-align:left;">'.$Firstname.'</th></tr>
   
   <tr style="background-color:#d29272;color:#000; font-family:Arial, Helvetica, sans-serif; font-size:12px;  height:30px; text-align:left;"><th width="50%"style="text-align:left;">&nbsp;EmailID</th><th width="50%"style="text-align:left;">'.$EmailID.'</th></tr>
   
   <tr style="color:#000; font-family:Arial, Helvetica, sans-serif; font-size:12px;  height:30px; text-align:left;"><th width="50%"style="text-align:left;">&nbsp;Address</th><th width="50%"style="text-align:left;">'.$Address.'</th></tr>
   
   <tr style="background-color:#d29272;color:#000; font-family:Arial, Helvetica, sans-serif; font-size:12px;  height:30px; text-align:left;"><th width="50%"style="text-align:left;">&nbsp;MobileNo</th><th width="50%"style="text-align:left;">'.$MobileNo.'</th></tr>
   
   <tr style="color:#000; font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left;  height:30px;"><th width="50%"style="text-align:left;">&nbsp;PhoneNo</th><th width="50%"style="text-align:left;">'.$PhoneNo.'</th></tr>
   
   <tr style="background-color:#d29272;color:#000; font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left;  height:30px;"><th width="50%"style="text-align:left;">&nbsp;Message</th><th width="50%"style="text-align:left;">'.$comment.'</th></tr>
   </table>'; 
   	

   	
   	$headers .= "From: $EmailID" . "\r\n";
   	
   	$headers  = 'MIME-Version: 1.0' . "\r\n";
   	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
   
   	mail($to,$subject,$message,$headers);
   	
   	header("location: thanks.html");  
   	
   	
   ?>

#2

Unless I’ve missed something it looks like you haven’t set a MIME type or a text alternative.

I would suggest using PHPMailer or SwiftMailer for sending emails (especially HTML emails) rather than the PHP mail() function. They are more reliable and you can set diagnostics mode (at least on PHPMailer - I’m not sure about Swift) which can help with debugging.


#4

Note that your submit check only surrounds the code that creates the local variables from the form inputs - it will then go on to send the email, even if the post check does not match, which will mean that none of your internal variables will exist. This may be one cause of your blank emails, even if not then I think the email should be within that if-then clause. If someone is calling your PHP code without going via the form, it will still send the emails.

A lot now suggest that instead of looking for a specific button setting to detect a form submission, you should check the request method:

if ($_SERVER['REQUEST_METHOD'] == "POST") { 

You should also consider sending the emails using a valid from-address on your mail host, rather than attempting to send them from whatever address the user types into the form. Many mail servers won’t send emails for domains that they are not configured to send.