fa_dy Posted February 18, 2013 Share Posted February 18, 2013 Hello guys, I have run into a little problem, I have a created an html form and I am trying to send its content to my email, when the submit button is pressed, using a php mailer script which I found athttp://www.freecontactform.com/email_form.php. Here's the form code: <form id="genius_com_w2l_form" class="genius_com_w2l_form" action="sendform.php" method="post"> <table class="genius_com_w2l_form_table"> <tbody> <tr class="genius_com_w2l_form_row"> <td class="genius_com_w2l_form_label_cell"><label id="genius_com_w2l_label_std_Salutation" for="genius_com_w2l_field_std_Salutation">*Salutation</label></td> <td class="genius_com_w2l_form_input_cell"> <div class="genius_com_w2l_field"><select required id="genius_com_w2l_field_std_Salutation" name="std_Salutation"> <option value="">(Not Selected)</option> <option value="Dr.">Dr.</option> <option value="Mr.">Mr.</option> <option value="Mrs.">Mrs.</option> <option value="Ms.">Ms.</option> <option value="Prof.">Prof.</option> </select> <div id="genius_com_w2l_errorMsg_std_Salutation" class="errorMsg"></div> </div></td> </tr> <tr class="genius_com_w2l_form_row"> <td class="genius_com_w2l_form_label_cell"><label id="genius_com_w2l_label_std_firstName" for="genius_com_w2l_field_std_firstName">*First Name</label></td> <td class="genius_com_w2l_form_input_cell"> <div class="genius_com_w2l_field"> <input required id="genius_com_w2l_field_std_firstName" type="text" name="std_firstName" value="" maxlength="40" /> <div id="genius_com_w2l_errorMsg_std_firstName" class="errorMsg"></div> </div></td> </tr> <tr class="genius_com_w2l_form_row"> <td class="genius_com_w2l_form_label_cell"><label id="genius_com_w2l_label_std_lastName" for="genius_com_w2l_field_std_lastName">*Last Name</label></td> <td class="genius_com_w2l_form_input_cell"> <div class="genius_com_w2l_field"> <input required id="genius_com_w2l_field_std_lastName" type="text" name="std_lastName" value="" maxlength="80" /> <div id="genius_com_w2l_errorMsg_std_lastName" class="errorMsg"></div> </div></td> </tr> <tr class="genius_com_w2l_form_row"> <td class="genius_com_w2l_form_label_cell"><label id="genius_com_w2l_label_std_email" for="genius_com_w2l_field_std_email">*E-mail Address</label></td> <td class="genius_com_w2l_form_input_cell"> <div class="genius_com_w2l_field"> <input required id="genius_com_w2l_field_std_email" type="email" name="std_email" value="" maxlength="255" /> <div id="genius_com_w2l_errorMsg_std_email" class="errorMsg"></div> </div></td> </tr> <tr class="genius_com_w2l_form_row"> <td class="genius_com_w2l_form_label_cell"><label id="genius_com_w2l_label_std_phone" for="genius_com_w2l_field_std_phone">*Phone</label></td> <td class="genius_com_w2l_form_input_cell"> <div class="genius_com_w2l_field"> <input required id="genius_com_w2l_field_std_phone" type="text" name="std_phone" value="" maxlength="30" /> <div id="genius_com_w2l_errorMsg_std_phone" class="errorMsg"></div> </div></td> </tr> <tr class="genius_com_w2l_form_row"> <td class="genius_com_w2l_form_label_cell"><label id="genius_com_w2l_label_cust_243593" for="genius_com_w2l_field_cust_243593">Skype Name</label></td> <td class="genius_com_w2l_form_input_cell"> <div class="genius_com_w2l_field"> <input id="genius_com_w2l_field_cust_243593" type="text" name="cust_243593" value="" maxlength="255" /> <div id="genius_com_w2l_errorMsg_cust_243593" class="errorMsg"></div> </div></td> </tr> <tr class="genius_com_w2l_form_row"> <td class="genius_com_w2l_form_label_cell"><label id="genius_com_w2l_label_cust_243596" for="genius_com_w2l_field_cust_243596">*Country of Citizenship</label></td> <td class="genius_com_w2l_form_input_cell"> <div class="genius_com_w2l_field"><select required id="genius_com_w2l_field_cust_243596" name="cust_243596"> <option value="">(Not Selected)</option> <option value="Afghanistan">Afghanistan</option> <option value="Albania">Albania</option> <option value="Algeria">Algeria</option> <option value="American Samoa">American Samoa</option> <option value="Andorra">Andorra</option> <option value="Angola">Angola</option> <option value="Anguilla">Anguilla</option> <option value="Antigua">Antigua</option> <option value="Argentina">Argentina</option> <option value="Armenia">Armenia</option> <option value="Aruba">Aruba</option> <option value="Australia">Australia</option> <option value="Austria">Austria</option> <option value="Azerbaijan">Azerbaijan</option> <option value="Bahamas">Bahamas</option> <option value="Bahrain">Bahrain</option> <option value="Bangladesh">Bangladesh</option> <option value="Barbados">Barbados</option> <option value="Barbuda">Barbuda</option> <option value="Belarus">Belarus</option> <option value="Belgium">Belgium</option> <option value="Belize">Belize</option> <option value="Benin">Benin</option> <option value="Bermuda">Bermuda</option> <option value="Bhutan">Bhutan</option> <option value="Bolivia">Bolivia</option> <option value="Bonaire">Bonaire</option> <option value="Bosnia">Bosnia</option> <option value="Botswana">Botswana</option> <option value="Brazil">Brazil</option> <option value="British Virgin Islands">British Virgin Islands</option> <option value="Brunei">Brunei</option> <option value="Bulgaria">Bulgaria</option> <option value="Burma">Burma</option> <option value="Burundi">Burundi</option> <option value="Cambodia">Cambodia</option> <option value="Cameroon">Cameroon</option> <option value="Canada">Canada</option> <option value="Cape Verde">Cape Verde</option> <option value="Cayman Islands">Cayman Islands</option> <option value="Central African Rep">Central African Rep</option> <option value="Chad">Chad</option> <option value="Channel Island">Channel Island</option> <option value="Chile">Chile</option> <option value="China">China</option> <option value="Colombia">Colombia</option> <option value="Congo">Congo</option> <option value="Cook Island">Cook Island</option> <option value="Costa Rica">Costa Rica</option> <option value="Croatia">Croatia</option> <option value="Curacao">Curacao</option> <option value="Cyprus">Cyprus</option> <option value="Czech Republic">Czech Republic</option> <option value="Denmark">Denmark</option> <option value="Djibouti">Djibouti</option> <option value="Dominica">Dominica</option> <option value="Dominican Republic">Dominican Republic</option> <option value="Ecuador">Ecuador</option> <option value="Egypt">Egypt</option> <option value="El Salvador">El Salvador</option> <option value="Equatorial Guinea">Equatorial Guinea</option> <option value="Eritrea">Eritrea</option> <option value="Estonia">Estonia</option> <option value="Ethiopia">Ethiopia</option> <option value="Faeroe Island">Faeroe Island</option> <option value="Fiji">Fiji</option> <option value="Finland">Finland</option> <option value="France">France</option> <option value="French Guiana">French Guiana</option> <option value="French Polynesia">French Polynesia</option> <option value="Gabon">Gabon</option> <option value="Gambia">Gambia</option> <option value="Georgia">Georgia</option> <option value="Germany">Germany</option> <option value="Ghana">Ghana</option> <option value="Gibraltar">Gibraltar</option> <option value="Great Britain">Great Britain</option> <option value="Greece">Greece</option> <option value="Greenland">Greenland</option> <option value="Grenada">Grenada</option> <option value="Guadeloupe">Guadeloupe</option> <option value="Guatemala">Guatemala</option> <option value="Guinea">Guinea</option> <option value="Guinea Bissau">Guinea Bissau</option> <option value="Guyana">Guyana</option> <option value="Haiti">Haiti</option> <option value="Honduras">Honduras</option> <option value="Hong Kong">Hong Kong</option> <option value="Hungary">Hungary</option> <option value="Iceland">Iceland</option> <option value="India">India</option> <option value="Indonesia">Indonesia</option> <option value="Iran">Iran</option> <option value="Iraq">Iraq</option> <option value="Ireland">Ireland</option> <option value="Israel">Israel</option> <option value="Italy">Italy</option> <option value="Ivory Coast">Ivory Coast</option> <option value="Jamaica">Jamaica</option> <option value="Japan">Japan</option> <option value="Jordan">Jordan</option> <option value="Kazakhstan">Kazakhstan</option> <option value="Kenya">Kenya</option> <option value="Korea">Korea</option> <option value="Kuwait">Kuwait</option> <option value="Kyrgyzstan">Kyrgyzstan</option> <option value="Laos">Laos</option> <option value="Latvia">Latvia</option> <option value="Lebanon">Lebanon</option> <option value="Liberia">Liberia</option> <option value="Liechtenstein">Liechtenstein</option> <option value="Lithuania">Lithuania</option> <option value="Luxembourg">Luxembourg</option> <option value="Macau">Macau</option> <option value="Macedonia">Macedonia</option> <option value="Madagascar">Madagascar</option> <option value="Malawi">Malawi</option> <option value="Malaysia">Malaysia</option> <option value="Maldives">Maldives</option> <option value="Mali">Mali</option> <option value="Malta">Malta</option> <option value="Marshall Islands">Marshall Islands</option> <option value="Martinique">Martinique</option> <option value="Mauritania">Mauritania</option> <option value="Mauritius">Mauritius</option> <option value="Mexico">Mexico</option> <option value="Micronesia">Micronesia</option> <option value="Moldova">Moldova</option> <option value="Monaco">Monaco</option> <option value="Mongolia">Mongolia</option> <option value="Montserrat">Montserrat</option> <option value="Morocco">Morocco</option> <option value="Mozambique">Mozambique</option> <option value="Myanmar">Myanmar</option> <option value="Namibia">Namibia</option> <option value="Nepal">Nepal</option> <option value="Netherlands">Netherlands</option> <option value="Netherlands Antilles">Netherlands Antilles</option> <option value="New Caledonia">New Caledonia</option> <option value="New Zealand">New Zealand</option> <option value="Nicaragua">Nicaragua</option> <option value="Niger">Niger</option> <option value="Nigeria">Nigeria</option> <option value="Northern Ireland">Northern Ireland</option> <option value="Norway">Norway</option> <option value="Oman">Oman</option> <option value="Pakistan">Pakistan</option> <option value="Palau">Palau</option> <option value="Panama">Panama</option> <option value="Papua New Guinea">Papua New Guinea</option> <option value="Paraguay">Paraguay</option> <option value="Peru">Peru</option> <option value="Philippines">Philippines</option> <option value="Poland">Poland</option> <option value="Polynesia">Polynesia</option> <option value="Portugal">Portugal</option> <option value="Qatar">Qatar</option> <option value="Reunion">Reunion</option> <option value="Romania">Romania</option> <option value="Russia">Russia</option> <option value="Rwanda">Rwanda</option> <option value="Saba">Saba</option> <option value="Saipan">Saipan</option> <option value="Saudi Arabia">Saudi Arabia</option> <option value="Scotland">Scotland</option> <option value="Senegal">Senegal</option> <option value="Serbia">Serbia</option> <option value="Seychelles">Seychelles</option> <option value="Sierra Leone">Sierra Leone</option> <option value="Singapore">Singapore</option> <option value="Slovak Republic">Slovak Republic</option> <option value="Slovenia">Slovenia</option> <option value="South Africa">South Africa</option> <option value="South Korea">South Korea</option> <option value="Spain">Spain</option> <option value="Sri Lanka">Sri Lanka</option> <option value="Sudan">Sudan</option> <option value="Suriname">Suriname</option> <option value="Swaziland">Swaziland</option> <option value="Sweden">Sweden</option> <option value="Switzerland">Switzerland</option> <option value="Syria">Syria</option> <option value="Taiwan">Taiwan</option> <option value="Tajikistan">Tajikistan</option> <option value="Tanzania">Tanzania</option> <option value="Thailand">Thailand</option> <option value="Togo">Togo</option> <option value="Trinidad-Tobago">Trinidad-Tobago</option> <option value="Tunisia">Tunisia</option> <option value="Turkey">Turkey</option> <option value="Turkmenistan">Turkmenistan</option> <option value="Uganda">Uganda</option> <option value="Ukraine">Ukraine</option> <option value="United Arab Emirates">United Arab Emirates</option> <option value="United Kingdom">United Kingdom</option> <option value="Uruguay">Uruguay</option> <option value="Uzbekistan">Uzbekistan</option> <option value="Vanuatu">Vanuatu</option> <option value="Vatican City">Vatican City</option> <option value="Venezuela">Venezuela</option> <option value="Vietnam">Vietnam</option> <option value="Wales">Wales</option> <option value="Yemen">Yemen</option> <option value="Zaire">Zaire</option> <option value="Zambia">Zambia</option> <option value="Zimbabwe">Zimbabwe</option> </select> <div id="genius_com_w2l_errorMsg_cust_243596" class="errorMsg"></div> </div></td> </tr> <tr class="genius_com_w2l_form_row"> <td class="genius_com_w2l_form_label_cell"><label id="genius_com_w2l_label_cust_243624" for="genius_com_w2l_field_cust_243624">Personal Net Worth</label></td> <td class="genius_com_w2l_form_input_cell"> <div class="genius_com_w2l_field"><select id="genius_com_w2l_field_cust_243624" name="cust_243624"> <option value="">(Not Selected)</option> <option value="$0 - $500,000">$0 - $500,000</option> <option value="$1 million - $3 million">$1 million - $3 million</option> <option value="$3 million - $10 million">$3 million - $10 million</option> <option value="$500,000 - $1 million">$500,000 - $1 million</option> <option value="> $10 million">> $10 million</option> </select> <div id="genius_com_w2l_errorMsg_cust_243624" class="errorMsg"></div> </div></td> </tr> <tr class="genius_com_w2l_form_row"> <td class="genius_com_w2l_form_label_cell"><label id="genius_com_w2l_label_cust_243607" for="genius_com_w2l_field_cust_243607">*Source of $500,000 for Investment</label></td> <td class="genius_com_w2l_form_input_cell"> <div class="genius_com_w2l_field"><select required id="genius_com_w2l_field_cust_243607" name="cust_243607"> <option value="">(Not Selected)</option> <option value="Emigrating clients">Emigrating clients</option> <option value="Gift from Parents">Gift from Parents</option> <option value="Loan">Loan</option> <option value="Personal Savings">Personal Savings</option> <option value="Sale of Business">Sale of Business</option> <option value="Sale of Real Estate">Sale of Real Estate</option> <option value="Sale of Stock">Sale of Stock</option> </select> <div id="genius_com_w2l_errorMsg_cust_243607" class="errorMsg"></div> </div></td> </tr> <tr class="genius_com_w2l_form_row"> <td class="genius_com_w2l_form_label_cell" valign="top"><label id="genius_com_w2l_label_cust_243595" for="genius_com_w2l_field_cust_243595">*Your Business/Occupation</label></td> <td class="genius_com_w2l_form_input_cell" valign="top"> <div class="genius_com_w2l_field"> <textarea required id="genius_com_w2l_field_cust_243595" name="cust_243595" rows="2" cols="20"></textarea> <div id="genius_com_w2l_errorMsg_cust_243595" class="errorMsg"></div> </div></td> </tr> <tr class="genius_com_w2l_form_row"> <td class="genius_com_w2l_form_label_cell"><label id="genius_com_w2l_label_cust_243598" for="genius_com_w2l_field_cust_243598">*Where Are You In the Process</label></td> <td class="genius_com_w2l_form_input_cell"> <div class="genius_com_w2l_field"><select required id="genius_com_w2l_field_cust_243598" name="cust_243598"> <option value="">(Not Selected)</option> <option value="Beginning to Investigate the Visa">Beginning to Investigate the Visa</option> <option value="Have Spoken with Some Regional Centers">Have Spoken with Some Regional Centers</option> <option value="Just Learning About the Visa">Just Learning About the Visa</option> <option value="Looking to Hire a Regional Center Consultant">Looking to Hire a Regional Center Consultant</option> <option value="Looking to Hire An Attorney Immediately">Looking to Hire An Attorney Immediately</option> <option value="Making Final Selection of Regional Center">Making Final Selection of Regional Center</option> <option value="Reviewing Various Regional Centers">Reviewing Various Regional Centers</option> </select> <div id="genius_com_w2l_errorMsg_cust_243598" class="errorMsg"></div> </div></td> </tr> <tr class="genius_com_w2l_form_row"> <td class="genius_com_w2l_form_label_cell" valign="top"><label id="genius_com_w2l_label_cust_243597" for="genius_com_w2l_field_cust_243597">*Your Situation & Goals</label></td> <td class="genius_com_w2l_form_input_cell" valign="top"> <div class="genius_com_w2l_field"> <textarea required id="genius_com_w2l_field_cust_243597" name="cust_243597" rows="5" cols="20"></textarea> <div id="genius_com_w2l_errorMsg_cust_243597" class="errorMsg"></div> </div></td> </tr> <tr class="genius_com_w2l_form_row"> <td class="genius_com_w2l_form_label_cell"><label id="genius_com_w2l_label_cust_243599" for="genius_com_w2l_field_cust_243599">Marital Status</label></td> <td class="genius_com_w2l_form_input_cell"> <div class="genius_com_w2l_field"><select id="genius_com_w2l_field_cust_243599" name="cust_243599"> <option value="">(Not Selected)</option> <option value="Divorced">Divorced</option> <option value="Married">Married</option> <option value="Single">Single</option> <option value="Widow(ed)">Widow(ed)</option> </select> <div id="genius_com_w2l_errorMsg_cust_243599" class="errorMsg"></div> </div></td> </tr> <tr class="genius_com_w2l_form_row"> <td class="genius_com_w2l_form_label_cell"><label id="genius_com_w2l_label_cust_243601" for="genius_com_w2l_field_cust_243601">No. of Unmarried Children Under 21</label></td> <td class="genius_com_w2l_form_input_cell"> <div class="genius_com_w2l_field"> <input id="genius_com_w2l_field_cust_243601" type="text" name="cust_243601" value="" maxlength="22" /> <div id="genius_com_w2l_errorMsg_cust_243601" class="errorMsg"></div> </div></td> </tr> <tr class="genius_com_w2l_form_row"> <td class="genius_com_w2l_form_label_cell"><label id="genius_com_w2l_label_cust_243600" for="genius_com_w2l_field_cust_243600">*English Fluency</label></td> <td class="genius_com_w2l_form_input_cell"> <div class="genius_com_w2l_field"><select required id="genius_com_w2l_field_cust_243600" name="cust_243600"> <option value="">(Not Selected)</option> <option value="Excellent">Excellent</option> <option value="Fair">Fair</option> <option value="Good">Good</option> <option value="None">None</option> <option value="Poor">Poor</option> <option value="Very Good">Very Good</option> </select> <div id="genius_com_w2l_errorMsg_cust_243600" class="errorMsg"></div> </div></td> </tr> </tbody> </table> <div><input class="btn" type="submit" value="Submit" /></div> </form> And here's the code which I've put inside the php mailer script: <?php if(isset($_POST["email"])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "email@hotmail.com"; $email_subject = "Your email subject line"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST["std_Salutation"]) || !isset($_POST["std_firstName"]) || !isset($_POST["std_lastName"]) || !isset($_POST["std_email"]) || !isset($_POST["std_phone"]) || !isset($_POST["cust_243593"]) || !isset($_POST["cust_243596"]) || !isset($_POST["cust_243624"]) || !isset($_POST["cust_243607"]) || !isset($_POST["cust_243595"]) || !isset($_POST["cust_243598"]) || !isset($_POST["cust_243597"]) || !isset($_POST["cust_243599"]) || !isset($_POST["cust_243601"]) || !isset($_POST["cust_243600"])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $salu = $_POST["std_Salutation"]; $first = $_POST["std_firstName"]; $last = $_POST["std_lastName"]; $email_from = $_POST["std_email"]; $phone = $_POST["std_phone"]; $sky = $_POST["cust_243593"]; $coun = $_POST["cust_243596"]; $per = $_POST["cust_243624"]; $sou = $_POST["cust_243607"]; $you = $_POST["cust_243595"]; $whe = $_POST["cust_243598"]; $your = $_POST["cust_243597"]; $mari = $_POST["cust_243599"]; $unm = $_POST["cust_243601"]; $eng = $_POST["cust_243600"]; $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Salutation: ".clean_string($salu)."\n"; $email_message .= "First Name: ".clean_string($first)."\n"; $email_message .= "Last Name: ".clean_string($last)."\n"; $email_message .= "E-mail Address: ".clean_string($email_from)."\n"; $email_message .= "Phone: ".clean_string($phone)."\n"; $email_message .= "Skype Name: ".clean_string($sky)."\n"; $email_message .= "Country of Citizenship: ".clean_string($coun)."\n"; $email_message .= "Personal Net Worth: ".clean_string($per)."\n"; $email_message .= "Source of 500,000 for Investment: ".clean_string($sou)."\n"; $email_message .= "Your Business/Occupation: ".clean_string($you)."\n"; $email_message .= "Where Are You In the Process: ".clean_string($whe)."\n"; $email_message .= "Your Situation & Goals: ".clean_string($your)."\n"; $email_message .= "Marital Status: ".clean_string($mari)."\n"; $email_message .= "No. of Unmarried Children Under 21: ".clean_string($unm)."\n"; $email_message .= "English Fluency: ".clean_string($eng)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> Thank you for contacting us. We will be in touch with you very soon. <?php } ?> The problem which I am facing is that when I fill the form and click on the submit button, the blank page of sendform.php opens up and no email is sent to my email account. Now when I use the demo form code from the php mailer site along with the php mailer script, it works like a charm and the email is sent to my email account. So I am assuming that something is wrong with my html form code. Please help me guys, it's urgent. Quote Link to comment https://forums.phpfreaks.com/topic/274648-cant-get-the-php-mailer-script-to-work/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.