Jump to content

php email form doesn't work?? What is wrong??Need help badd!


siral3x

Recommended Posts

I don't receive any errors, but it won't send me the email...I don't know what else to do :(

I have the actual form in 1 file and the processor in a 2nd file with the code as follows:

form.html :

<form action="process.php" method="post">
<table border=1>
<tr>
<tr>
<td>First name:</td>
<td align="center"><input type="text" name="name" size="15" maxlength="30"></td>
</tr>
<tr>
<td>Last name:</td>
<td align="center"><input type="text" name="last_name" size="15" maxlength="30"></td>
</tr>
<tr>
<td>Address:</td>
<td align="center"><input type="text" name="address" size="15" maxlength="30"></td>
</tr>
<tr>
<td>City:</td>
<td align="center"><input type="text" name="city" size="15" maxlength="30"></td>
</tr>
<tr>
<td>State:</td>
<td align="center"><input type="text" name="state" size="15" maxlength="30"></td>
</tr>
<tr>
<td>Postal Code:</td>
<td align="center"><input type="text" name="zip" size="15" maxlength="30"></td>
</tr>
<tr>
<td>Country:</td>
<td align="center"><input type="text" name="country" size="15" maxlength="30"></td>
</tr>
<tr>
<td>E-mail:</td>
<td align="center"><input type="text" name="mail" size="15" maxlength="30"></td>
</tr>
<tr>
<td>Telephone:</td>
<td align="center"><input type="text" name="tel" size="15" maxlength="30"></td>
</tr>
</table>
<div align="center"><center><table border="0"
            width="480">
                <tr>
                    <td align="center"><input type="submit"
                    value="Submit Order"></td>
                    <td align="center"><input type="reset"
                    value="Reset form"></td>
                </tr>
            </table>
            </center></div>

 

and then process.php:

<?php
$to = "[email protected]";
$subject = "Put your subject line here";
$tmp = array();
foreach($_POST as $fld => $val)
    if ($fld != 'submit')
        $tmp[] = $fld . ': ' . stripslashes($val);
$body = implode("\are\n",$tmp) . "\are\n";
$headers = 'From: ' . $_POST['name'] . ' <' . $_POST['mail'] . '>';
mail($to,$subject,$body,$headers);
echo "<h5>YOUR REQUEST HAS BEEN SENT! WE WILL GET BACK TO YOU SOON!</h5>";
?>

 

Like I said I receive no errors but it won't send me the email!!!

Any solutions??

thx in advance

ALEX

As you can see here, http://us.php.net/manual/en/function.mail.php#id4752425, headers need to be separated by "\r\n"...including the last one.

 

WTF is "\are"? 

 

I know it's not always necessary to use the curly braces ( {} ), however, since your script isn't functioning properly, you should make sure to use them to eliminate that as a source of error.

 

Ensure error reporting and display errors are turned on:

 

ini_set("display_errors", 1);
error_reporting(E_ALL ^ E_NOTICE);

 

<?php
ini_set("display_errors", 1);
error_reporting(E_ALL ^ E_NOTICE);

$to = "[email protected]";
$subject = "Put your subject line here";
$tmp = array();
foreach($_POST as $fld => $val) {
    if ($fld != 'submit') {
        $tmp[] = $fld . ': ' . stripslashes($val);
}
}

$body = implode("\r\n",$tmp) . "\r\n";

$headers = 'From: ' . $_POST['name'] . ' <' . $_POST['mail'] . '>' . "\r\n";

if (mail($to,$subject,$body,$headers)) {
echo "<h5>YOUR REQUEST HAS BEEN SENT! WE WILL GET BACK TO YOU SOON!</h5>";
} else {
echo "An error has occurred";
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.