Jump to content

PhP error, Failure


PoH

Recommended Posts

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!

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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"

Link to comment
Share on other sites

 

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");

}
   ?>

Link to comment
Share on other sites

 

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.