PoH Posted October 4, 2009 Share Posted October 4, 2009 Here are my two scripts I have checked them lots but still can't figure it out: Here's the first 1 for people to enter their info on: <form action="test.php" method="post"> <table width="444" border="0" cellspacing="2" cellpadding="0"> <tr> <td width="41%" class="bodytext">Your name:</td> <td width="59%"><p> <input name="name" type="text" id="name" size="32" /> </p></td> </tr> <tr> <td class="bodytext">Email address:</td> <td><p> <input name="email" type="text" id="email" size="32" /> </p></td> </tr> <tr> <td width="41%" class="bodytext">Age:</td> <td width="59%"><p> <input name="age" type="text" id="name" size="32" /> </p></td> </tr> <tr> <td width="41%" class="bodytext">Xfire:</td> <td width="59%"><p> <input name="xfire" type="text" id="name" size="32" /> </p></td> </tr> <tr> <td width="41%" class="bodytext">Will you follow the rules?</td> <td width="59%"><p> <input name="rules" type="text" id="name" size="32" /> </p></td> </tr> <tr> <td width="41%" class="bodytext">Can you host a dedicated server?</td> <td width="59%"><p> <input name="host" type="text" id="name" size="32" /> </p></td> </tr> <tr> <td width="41%" class="bodytext">Will you donate? If so how much?</td> <td width="59%"><p> <input name="donate" type="text" id="name" size="32" /> </p></td> </tr> <tr> <td width="41%" class="bodytext">Reason why you want to join:</td> <td width="59%"><p> <input name="reason" type="text" id="name" size="32" /> </p></td> </tr> <td class="bodytext"> </td> <td align="left" valign="top"><input type="submit" name="Submit" value="Send" /></td> </tr> </table> </form> And here's the test.php (method): <?php if ($_POST["email"]<>'') { $ToEmail = 'mtb_dj_4_life@live.com'; $EmailSubject = 'POH Clan Apply Form '; $mailheader = "Name: ".$_POST["email"]."\r\n"; $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $MESSAGE_BODY = "Name: ".$_POST["name"]."<br>"; $MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>"; $MESSAGE_BODY .= "Age:".nl2br($_POST["age"])."<br>"; $MESSAGE_BODY .= "Xfire:".nl2br($_POST["xfire"])."<br>"; $MESSAGE_BODY .= "Follow the rules?:".nl2br($_POST["rules"])."<br>"; $MESSAGE_BODY .= "Host:".nl2br($_POST["host"])."<br>"; $MESSAGE_BODY .= "Donate:".nl2br($_POST["donate"])."<br>"; $MESSAGE_BODY .= "Reason to join:".nl2br($_POST["reason"])."<br>"; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); ?> MESSAGE <?php } else { ?> <form action="test.php" method="post"> <table width="444" border="0" cellspacing="2" cellpadding="0"> <tr> <td width="41%" class="bodytext">Your name:</td> <td width="59%"><p> <input name="name" type="text" id="name" size="32" /> </p></td> </tr> <tr> <td class="bodytext">Email address:</td> <td><p> <input name="email" type="text" id="email" size="32" /> </p></td> </tr> <tr> <td width="41%" class="bodytext">Age:</td> <td width="59%"><p> <input name="age" type="text" id="name" size="32" /> </p></td> </tr> <tr> <td width="41%" class="bodytext">Xfire:</td> <td width="59%"><p> <input name="xfire" type="text" id="name" size="32" /> </p></td> </tr> <tr> <td width="41%" class="bodytext">Will you follow the rules?</td> <td width="59%"><p> <input name="rules" type="text" id="name" size="32" /> </p></td> </tr> <tr> <td width="41%" class="bodytext">Can you host a dedicated server?</td> <td width="59%"><p> <input name="host" type="text" id="name" size="32" /> </p></td> </tr> <tr> <td width="41%" class="bodytext">Will you donate? If so how much?</td> <td width="59%"><p> <input name="donate" type="text" id="name" size="32" /> </p></td> </tr> <tr> <td width="41%" class="bodytext">Reason why you want to join:</td> <td width="59%"><p> <input name="reason" type="text" id="name" size="32" /> </p></td> </tr> <td class="bodytext"> </td> <td align="left" valign="top"><input type="submit" name="Submit" value="Send" /></td> </tr> </table> </form> <?php }; ?> Thanks HEAPS! Quote Link to comment https://forums.phpfreaks.com/topic/176489-php-error-failure/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 4, 2009 Share Posted October 4, 2009 Unless you bother to state exactly what problem you are having and what you see in front of you when you try your code, no one can directly help you. We are not standing next to you. If you aren't, can't, or won't provide relevant information in your post, you cannot get a relevant reply. For all we know, you don't have php installed on your web server. Quote Link to comment https://forums.phpfreaks.com/topic/176489-php-error-failure/#findComment-930340 Share on other sites More sharing options...
PoH Posted October 5, 2009 Author Share Posted October 5, 2009 Thanks for your reply: We'll I do have PhP installed as I have Forums (PhP) and script use to work until I edited and the problem is when ever someone submits this form the get the error message (Failure) So I just want someone to reply to me with a working script, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/176489-php-error-failure/#findComment-930341 Share on other sites More sharing options...
PFMaBiSmAd Posted October 5, 2009 Share Posted October 5, 2009 To troubleshoot why the mail() function call is failing, add the following two lines of code immediately after the first opening <?php tag in test.php - ini_set("display_errors", "1"); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/176489-php-error-failure/#findComment-930343 Share on other sites More sharing options...
PoH Posted October 5, 2009 Author Share Posted October 5, 2009 To troubleshoot why the mail() function call is failing, add the following two lines of code immediately after the first opening <?php tag in test.php - ini_set("display_errors", "1"); error_reporting(E_ALL); Still said "Failure" Quote Link to comment https://forums.phpfreaks.com/topic/176489-php-error-failure/#findComment-930361 Share on other sites More sharing options...
redarrow Posted October 5, 2009 Share Posted October 5, 2009 try this bro? <?php if (isset($_POST['submit']) && (isset($_POST['email']))) { $ToEmail = 'mtb_dj_4_life@live.com'; $EmailSubject = 'POH Clan Apply Form '; $mailheader = "Name: ".$_POST["email"]."\r\n"; $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $MESSAGE_BODY = "Name: ".$_POST["name"]."<br>"; $MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>"; $MESSAGE_BODY .= "Age:".nl2br($_POST["age"])."<br>"; $MESSAGE_BODY .= "Xfire:".nl2br($_POST["xfire"])."<br>"; $MESSAGE_BODY .= "Follow the rules?:".nl2br($_POST["rules"])."<br>"; $MESSAGE_BODY .= "Host:".nl2br($_POST["host"])."<br>"; $MESSAGE_BODY .= "Donate:".nl2br($_POST["donate"])."<br>"; $MESSAGE_BODY .= "Reason to join:".nl2br($_POST["reason"])."<br>"; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/176489-php-error-failure/#findComment-930398 Share on other sites More sharing options...
PoH Posted October 6, 2009 Author Share Posted October 6, 2009 try this bro? <?php if (isset($_POST['submit']) && (isset($_POST['email']))) { $ToEmail = 'mtb_dj_4_life@live.com'; $EmailSubject = 'POH Clan Apply Form '; $mailheader = "Name: ".$_POST["email"]."\r\n"; $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $MESSAGE_BODY = "Name: ".$_POST["name"]."<br>"; $MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>"; $MESSAGE_BODY .= "Age:".nl2br($_POST["age"])."<br>"; $MESSAGE_BODY .= "Xfire:".nl2br($_POST["xfire"])."<br>"; $MESSAGE_BODY .= "Follow the rules?:".nl2br($_POST["rules"])."<br>"; $MESSAGE_BODY .= "Host:".nl2br($_POST["host"])."<br>"; $MESSAGE_BODY .= "Donate:".nl2br($_POST["donate"])."<br>"; $MESSAGE_BODY .= "Reason to join:".nl2br($_POST["reason"])."<br>"; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); } ?> I don't get a failure but no email gets sent. Quote Link to comment https://forums.phpfreaks.com/topic/176489-php-error-failure/#findComment-931777 Share on other sites More sharing options...
PFMaBiSmAd Posted October 6, 2009 Share Posted October 6, 2009 That's because $_POST['submit'] does not match what your form sends, so that was a waste of your time. If the two lines of code that I posted and you added did not result in any error messages from the mail() function, then your mail server has likely been configured to operate 'silently' and not return error messages. This is generally being done to prevent hackers from feeding invalid information to a mail server in order to triggers errors that then gives them information about the mail server. You are using a Name: field in the headers. To the best of my knowalge, there is no such SMTP field and you are not using a From: field. It is likely one or both of these things is causing the mail() function to fail. You should be using a From: field with an email address in it that is hosted at the sending mail server. The Reply-to: address should be the email that the visitor entered, which is what you have now. There should be no Name: field. Quote Link to comment https://forums.phpfreaks.com/topic/176489-php-error-failure/#findComment-931789 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.