Re: Where is the email address?



..oO(nobody@xxxxxxxxxxxxxxx)

I did a simple mail script to forward a form submitted email address.

The email address is passed to the subject and message fields. When I
get the email, the email address field is blank. I can't seem to find
what's wrong. I'm hoping an experienced pair of eyes might see something
that this php novice doesn't see. Thank you in advance for your time and
words. George.


In my index.php page I have:

<form action="indexP.php" method="POST">
<input type="text" name="email" size="30">
<input type="submit" value="Join!">
</form>


In my indexP.php page I have:

<?php
$today = getdate();
$month = $today['month'];
$mday = $today['mday'];
$year = $today['year'];
$currentDate = "$month $mday, $year";

$subject = "Newsletter Request from mydomain.com: " . $_POST['email'];

$message = "Request Date: $currentDate Requested By: " .
$_POST['email'] . "\r" . "1. E-mail: " . $_POST['email'] . "\r\r";
$headers = "From: info@xxxxxxxxxxxx" . "\n\r";

You should decide for one type of linebreaks and not mix various of them
at will. Either use "\r\n" or just "\n".

You should also read about mail header injection and how to prevent it.
Your subject line can be abused to inject arbitrary headers.

mail("info@mydomain", $subject, $message, $headers);
?>

The email appears in my inbox but the email field is missing:

From: <info@xxxxxxxxxxxx>
Date: Thu, 22 May 2008 06:12:42 -0400
To: <info@xxxxxxxxxxxx>
Subject: Newsletter Request from mydomain.com:


Request Date: May 22, 2008 Requested By:
1. E-mail:

What's the setting of error_reporting (should be E_ALL|E_STRICT) and
display_errors in your php.ini? Any error messages? What does

print '<pre>';
var_dump($_POST);
print '</pre>';

show?

Micha
.