1 Reply Latest reply on Sep 27, 2011 9:54 PM by nmbnmb

    Contact Form Blank Emails


      Hi Guys


      Iv set up a contact form on my website but I am frequently getting emails with blank fields sent to my email address, like this:











      The HTML Code is:




      <div class="contactform">

                  <form method="post" action="contactformprocess.php">

                    <fieldset><legend> CONTACT DETAILS </legend>

                      <p><label for="contact_title" class="left">Title:</label>

                         <select name="contact_title" id="contact_title" class="combo">

                           <option value="choose"> Select... </option>


      <option value="dr"> Dr. </option>



      <option value="miss"> Miss. </option>

                           <option value="mr"> Mr. </option>

                           <option value="mrs"> Mrs. </option></select></p>


                        <label for="contact_firstname" class="left">Name:</label>

                        <span id="sprytextfield1">

                        <input type="text" name="contact_firstname" id="contact_firstname" class="field" value="" tabindex="1" />

                      <span class="textfieldRequiredMsg"><br />

                      Name required.</span></span></p>

                   <p><label for="contact_country" class="left">Country:</label>

                         <select name="contact_country" id="contact_country" class="combo">

                           <option value="choose" selected="selected"> Select... </option>

                           <option value="United Kingdom"> United Kingdom </option>

                           <option value="United States"> United States </option>

                           <option value="Other"> Other </option></select></p>

                      <p> </p>

                      <p><label for="contact_email" class="left">Email:</label>

                        <span id="sprytextfield2">

                        <input type="text" name="contact_email" id="contact_email" class="field" value="" tabindex="2" />

                      <span class="textfieldRequiredMsg"> Valid Email Address is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></p>

                     <p><label for="contact_url" class="left">Website:</label>

                         <input type="text" name="contact_url" id="contact_url" class="field" value="" tabindex="3" /></p>


                    <fieldset><legend> MESSAGE DETAILS </legend>

                      <p><label for="contact_subject" class="left">Subject:</label>

                        <span id="sprytextfield3">

                        <input type="text" name="contact_subject" id="contact_subject" class="field" value="" tabindex="4" />

                      <span class="textfieldRequiredMsg"> Please put a subject.</span></span></p>

                      <p> </p>

                      <p><label for="contact_message" class="left">Message:</label>

                        <span id="sprytextarea1">

                        <textarea name="contact_message" id="contact_message" cols="45" rows="10"tabindex="5"></textarea>

                      <span class="textareaRequiredMsg"> Please write a message.</span></span></p>

                      <p><input type="submit" name="submit" id="submit" class="button" value="Send message" tabindex="6" /></p>






      And the PHP Code is:








      * @Web Contact Page PHP Script

      * @author helpvid@ymail.com - http://www.helpvid.net

      * @version 1.0.0

      * @date January  05, 2010

      * @category Helpvid PHP Script for Contact page

      * @copyright (c) 2010 @helpvid.net (www.helpvid.net)

      * @Creative Commons Attribution-No Derivative Works 2.0 UK: England & Wales License.

      * @Creative Commons Attribution-No Derivative Works 2.5 UK: SCOTLAND License.

      * @Creative Commons Attribution-No Derivative Works 3.0 United States License.






      /* Email Variables */

      $emailSubject = 'contactformprocess!'; /*Make sure this matches the name of your file*/

      $webMaster = 'dan_spooner@live.co.uk, despooner@aol.com';



      /*design by Mark Leroy @ http://www.helpvid.net*/



      /* Data Variables */



      $contact_titleField = $_POST['contact_title'];

      $contact_firstnameField = $_POST['contact_firstname'];

      $contact_countryField = $_POST['contact_country'];

      $contact_emailField = $_POST['contact_email'];

      $contact_urlField = $_POST['contact_url'];

      $contact_subjectField = $_POST['contact_subject'];

      $contact_messageField = $_POST['contact_message'];







      $body = <<<EOD


      Title: $contact_title <br>

      Name: $contact_firstname <br>

      Country: $contact_country <br>

      Email: $contact_email <br>

      URL: $contact_url <br>

      Subject: $contact_subject <br>

      Message: $contact_message <br>


      $headers = "From: $email\r\n";

      $headers .= "Content-type: text/html\r\n";

      $success = mail($webMaster, $emailSubject, $body,






      /* Results rendered as HTML */

      $theResults = <<<EOD



      <title>sent message</title>

      <meta http-equiv="refresh" content="3;http://ds-innovations.com/">

      <style type="text/css">


      body {

      background-color: #666

      font-family: Verdana, Arial, Helvetica, sans-serif;

      font-size: 20px;

      font-style: normal;

      line-height: normal;

      font-weight: normal;

      color: #fec001;

      text-decoration: none;

      padding-top: 200px;

      margin-left: 150px;

      width: 800px;





      <div align="center">Thank you for your interest! Your message has been successfully sent and we will get back to you shortly! </div>





      echo "$theResults";




      Any help would be greatly appreciated guys!