LostKID Posted July 30, 2009 Share Posted July 30, 2009 hi there im having problems with some php work, i have never been much a php coder all though i really want to get into it when i have more time. A client our our has asked for a form and we have resorted in having to use a template from off a website. For some reason the Client isnt recieving the emails. Could anybody help? <form method="POST" action="contact.php"> <div align="center"> <table border="0" align="left" cellpadding="0" cellspacing="3"> <tr> <td colspan="2" align="left" valign="middle"><span class="style3">Instant Email!</span><br /> Please fill out all the fields marked: (<span class="style2"> *</span> )</td> </tr> <tr> <td align="left" valign="middle"> </td> <td align="left"> </td> </tr> <tr> <td width="98" align="left" valign="middle">Company:</td> <td width="573" align="left"><font face="Arial" size="3"> <input name="Company" type="text" size="42" /> </font></td> </tr> <tr> <td colspan="2" align="left" valign="middle"><img src="seperator.jpg" width="200" height="10" /></td> </tr> <tr> <td width="98" align="left" valign="middle">First Name: (<span class="style2"> *</span> )</td> <td width="573" align="left"><font face="Arial" size="3"> <input type="text" name="FirstName" size="42" /> </font></td> </tr> <tr> <td width="98" align="left" valign="middle">Last Name: (<span class="style2"> *</span> )</td> <td width="573" align="left"><font face="Arial" size="3"> <input type="text" name="LastName" size="42" /> </font></td> </tr> <tr> <td colspan="2" align="left" valign="middle"><img src="seperator.jpg" width="200" height="10" /></td> </tr> <tr> <td width="98" align="left" valign="middle">Email:(<span class="style2"> *</span> )</td> <td width="573" align="left"><font face="Arial" size="3"> <input type="text" name="Email" size="42" /> </font></td> </tr> <tr> <td width="98" align="left" valign="middle">Tel:</td> <td width="573" align="left"><font face="Arial" size="3"> <input name="Tel" type="text" size="42" /> </font></td> </tr> <tr> <td width="98" align="left" valign="middle">Address:</td> <td width="573" align="left"><font size="3" face="Arial"> <input type="text" name="Address" size="42" /> </font></td> </tr> <tr> <td width="98" align="left" valign="middle">Country:</td> <td width="573" align="left"><font size="3" face="Arial"> <input type="text" name="County" size="42" /> </font></td> </tr> <tr> <td width="98" align="left" valign="middle">Postcode:</td> <td width="573" align="left"><font size="3" face="Arial"> <input type="text" name="PostCode" size="42" /> </font></td> </tr> <tr> <td colspan="2" align="left" valign="middle"><img src="seperator.jpg" width="200" height="10" /></td> </tr> <tr> <td width="98" align="left" valign="middle"><font face="Arial">Subject:</font></td> <td width="573" align="left"><font size="3" face="Arial"> <select name="subject"> <option selected>General enquiry</option> <option>Request for information</option> <option>Request for brochure</option> <option>Request for quotation</option> <option>Place an order</option> <option>Make a booking</option> <option>Availability</option> <option>Other</option> </select> </font></td> </tr> <tr> <td colspan="2" align="left" valign="middle"> </td> </tr> <tr> <td width="98" align="left" valign="top">Message:(<span class="style2"> *</span> )</td> <td width="573" align="left"><font size="3" face="Arial"> <textarea accesskey="9" name="Message" rows="8" cols="60"></textarea> </font></td> </tr> <tr> <td colspan="2" align="left" valign="top"><img src="seperator.jpg" width="200" height="10" /></td> </tr> <tr> <td width="98" align="left" valign="top"><font face="Arial">Contact Preferences:</font></td> <td width="573" align="left"><table width="300" border="0" cellspacing="3" cellpadding="0"> <tr> <td><font face="Arial"><font size="3"> <input type="checkbox" name="Anytime" value="Yes" /> </font>Anytime</font></td> <td><font face="Arial"><font size="3"> <input type="checkbox" name="OfficeHours" value="Yes" /> </font>Office Hours</font></td> </tr> <tr> <td><font face="Arial"><font size="3"> <input type="checkbox" name="Evenings" value="Yes" /> </font>Evenings</font></td> <td><font face="Arial"><font size="3"> <input type="checkbox" name="Weekends" value="Yes" /> </font>Weekends</font></td> </tr> </table></td> </tr> <tr> <td colspan="2" align="left" valign="middle"><img src="seperator.jpg" width="200" height="10" /></td> </tr> <tr> <td width="98" align="left" valign="middle"> </td> <td width="573" align="left"><div align="right"><font size="3" face="Arial"> <input type="submit" name="submit" value=" Submit " style="font-weight: 700" /> </font></div></td> </tr> </table> </div> </form> <?php //Aquire Values $EmailTo = "email address here"; $Subject = Trim(stripslashes($_POST['subject'])); $Company = Trim(stripslashes($_POST['Company'])); $FirstName = Trim(stripslashes($_POST['FirstName'])); $LastName = Trim(stripslashes($_POST['LastName'])); $Email = Trim(stripslashes($_POST['Email'])); $Tel = Trim(stripslashes($_POST['Tel'])); $Address = Trim(stripslashes($_POST['Address'])); $County = Trim(stripslashes($_POST['County'])); $PostCode = Trim(stripslashes($_POST['PostCode'])); $Message = Trim(stripslashes($_POST['Message'])); $Anytime = Trim(stripslashes($_POST['Anytime'])); $OfficeHours = Trim(stripslashes($_POST['OfficeHours'])); $Evenings = Trim(stripslashes($_POST['Evenings'])); $Weekends = Trim(stripslashes($_POST['Weekends'])); // Feild Validation $validationOK=true; if (Trim($FirstName)=="") $validationOK=false; if (Trim($LastName)=="") $validationOK=false; if (Trim($Email)=="") $validationOK=false; if (Trim($Message)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">"; exit; } // Email Layout $headers = "From: " . $Company ." ". $FirstName ." ". $LastName . "<" . $Email .">\r\n"; $headers .= "Reply-To: " . $Email . "\r\n"; $Body = ""; $Body .= "Company: "; $Body .= $Company; $Body .= "\n"; $Body .= "Name: "; $Body .= $FirstName; $Body .= " "; $Body .= $LastName; $Body .= "\n\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $Body .= "Tel: "; $Body .= $Tel; $Body .= "\n"; $Body .= "Address: "; $Body .= $Address; $Body .= "\n"; $Body .= "County: "; $Body .= $County; $Body .= "\n"; $Body .= "PostCode: "; $Body .= $PostCode; $Body .= "\n\n"; $Body .= "Subject: "; $Body .= $Subject; $Body .= "\n"; $Body .= "Message: "; $Body .= $Message; $Body .= "\n\n Please Contact me at:"; $Body .= "Anytime: "; $Body .= $Anytime; $Body .= "\n"; $Body .= "OfficeHours: "; $Body .= $OfficeHours; $Body .= "\n"; $Body .= "Evenings: "; $Body .= $Evenings; $Body .= "\n"; $Body .= "Weekends: "; $Body .= $Weekends; $Body .= "\n"; // Send Email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // Redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.html\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">"; } ?> any help would be extremely helpful. thank you! Link to comment https://forums.phpfreaks.com/topic/168118-solved-problems-with-online-email-form-help/ Share on other sites More sharing options...
phpSensei Posted July 30, 2009 Share Posted July 30, 2009 the trim() function does not have a capital letter. its all lower case Link to comment https://forums.phpfreaks.com/topic/168118-solved-problems-with-online-email-form-help/#findComment-886668 Share on other sites More sharing options...
phpSensei Posted July 30, 2009 Share Posted July 30, 2009 and fix your IF/ELSE.... some problems there too. I tested to see if your vars are coming through, works fine, and goes through the ok.html try <?php <?php //Aquire Values $EmailTo = ""; $Subject = trim(stripslashes($_POST['subject'])); $Company = trim(stripslashes($_POST['Company'])); $FirstName = trim(stripslashes($_POST['FirstName'])); $LastName = trim(stripslashes($_POST['LastName'])); $Email = trim(stripslashes($_POST['Email'])); $Tel = trim(stripslashes($_POST['Tel'])); $Address = trim(stripslashes($_POST['Address'])); $County = trim(stripslashes($_POST['County'])); $PostCode = trim(stripslashes($_POST['PostCode'])); $Message = trim(stripslashes($_POST['Message'])); $Anytime = trim(stripslashes($_POST['Anytime'])); $OfficeHours = trim(stripslashes($_POST['OfficeHours'])); $Evenings = trim(stripslashes($_POST['Evenings'])); $Weekends = trim(stripslashes($_POST['Weekends'])); // TEST YOUR VARS ARE PASSING THROUGH print_r($_POST); // Feild Validation $validationOK=true; if (trim($FirstName)==""){ $validationOK=false; }elseif(trim($LastName)=="") { $validationOK=false; }elseif (trim($Email)=="") { $validationOK=false; }elseif (trim($Message)=="") { $validationOK=false; } if ($validationOK == false) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">"; exit; }else{ // Email Layout $headers = "From: " . $Company ." ". $FirstName ." ". $LastName . "<" . $Email .">\r\n"; $headers .= "Reply-To: " . $Email . "\r\n"; $Body = ""; $Body .= "Company: "; $Body .= $Company; $Body .= "\n"; $Body .= "Name: "; $Body .= $FirstName; $Body .= " "; $Body .= $LastName; $Body .= "\n\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $Body .= "Tel: "; $Body .= $Tel; $Body .= "\n"; $Body .= "Address: "; $Body .= $Address; $Body .= "\n"; $Body .= "County: "; $Body .= $County; $Body .= "\n"; $Body .= "PostCode: "; $Body .= $PostCode; $Body .= "\n\n"; $Body .= "Subject: "; $Body .= $Subject; $Body .= "\n"; $Body .= "Message: "; $Body .= $Message; $Body .= "\n\n Please Contact me at:"; $Body .= "Anytime: "; $Body .= $Anytime; $Body .= "\n"; $Body .= "OfficeHours: "; $Body .= $OfficeHours; $Body .= "\n"; $Body .= "Evenings: "; $Body .= $Evenings; $Body .= "\n"; $Body .= "Weekends: "; $Body .= $Weekends; $Body .= "\n"; // Send Email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // Redirect to success page if ($success){ } else{ } } ?> ?> Link to comment https://forums.phpfreaks.com/topic/168118-solved-problems-with-online-email-form-help/#findComment-886670 Share on other sites More sharing options...
LostKID Posted July 30, 2009 Author Share Posted July 30, 2009 Thank you, is that what is stopping the client from recieving the email do you think? im going to try it out now. Link to comment https://forums.phpfreaks.com/topic/168118-solved-problems-with-online-email-form-help/#findComment-886671 Share on other sites More sharing options...
phpSensei Posted July 30, 2009 Share Posted July 30, 2009 Thank you, is that what is stopping the client from recieving the email do you think? im going to try it out now. yes the function will stop running because its not a function, but an alien character to PHP. edit: I fixed my post, try that script Link to comment https://forums.phpfreaks.com/topic/168118-solved-problems-with-online-email-form-help/#findComment-886675 Share on other sites More sharing options...
LostKID Posted July 30, 2009 Author Share Posted July 30, 2009 Works perfectly, thank you so much you have been very helpful. I have some coding knowledge in Actionscript so i could tell straight away that trim was fixed when it highlighted as a function tag thank you again! Link to comment https://forums.phpfreaks.com/topic/168118-solved-problems-with-online-email-form-help/#findComment-886682 Share on other sites More sharing options...
phpSensei Posted July 30, 2009 Share Posted July 30, 2009 Works perfectly, thank you so much you have been very helpful. I have some coding knowledge in Actionscript so i could tell straight away that trim was fixed when it highlighted as a function tag thank you again! glad i helped. havnt said this in a loooooooooong time but "make sure you click the SOLVED button". lol Link to comment https://forums.phpfreaks.com/topic/168118-solved-problems-with-online-email-form-help/#findComment-886686 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.