Re: [PHP] Beginner Questions regarding Mail and Forms



On h, 2007-02-12 at 14:16 +0100, Matthias S. wrote:
hi zoltan,

thanks for your reply. i've tried the -f switch but the only effect it has
is an error message ;)

Warning: mail() [function.mail]: SAFE MODE Restriction in effect. The fifth
parameter is disabled in SAFE MODE.

ehh, sorry, I didn't think you use safe mode. If you can not switch it
off, then try to contact your system admin to install a sendmail
alternative which can be configured to read the reply-to header from the
mail headers passed to it by the caller - AFAIK sendmail itself cannot
be configured this way, but I might be wrong


as for the age value:
it is simply incorrect because it is always empty... input might be for
example 25, but the var $age contains always an empty string.

well, you should check the field in your form. does it have exactly the
same name? maybe you misspelled it... (don't forget that it is
case-sensitive, so _txtAge is not equal with _txtage for example)

greets
Zoltán Németh


Can you help? I'm a programmer (C++), but have never used PHP before. The
concepts are clear to me, but I must be missing here something essential.

Thanks again, Matthias

"Nmeth Zoltn" <znemeth@xxxxxxxxxxxxxx> schrieb im Newsbeitrag
news:1171279620.5056.16.camel@xxxxxxxxxxxxxxx
On h, 2007-02-12 at 11:13 +0100, Matthias S. wrote:
Hi there,

I've got two bloody beginner questions: I've created a form with various
text input fields. One is to hold a numeric value (age). Upon
submission, I
try to retrieve the value of this field like this:

$age = $_POST['_txtAge'];

later, I use the $age variable to create a message...

$message = "Name: " . $name . "\n";
$message .= "Email: " .$email . "\n";
$message .= "Age: " . $age . "\n";
$message .= "Gender: " . $gender . "\n";
$message .= "Info: " . $info;

.... then I send the message:

mail("bla@xxxxxxx", "A Request", $message, _getMailHeaders($name,
email));

Now on to my questions:
$message contains the values of all fields correctly except the age
field
(input of all others are alphabetic, only age has numeric content). Why
is
this?

what do you mean by incorrect? what is the test input you give and what
result do you get?


Secondly, mail sends my message correctly. But the return adresse set in
_getMailHeaders is not used. Instead, some identification from the
server is
used. Why is that?

it is (if you use sendmail on the server) because sendmail sets reply-to
to the user running it by default. so it gets set to the user the script
runs as (usually www-data or something like that). it can be overridden
by the "-f" switch I think. like this:

mail($to, $subject, $message, $headers, "-f".$frommail);


hope that helps
Zoltn Nmeth


Here the function _getMailHeaders:

function _getMailHeaders($senderName, $senderAddress) {

ini_set(sendmail_from, $senderAddress);

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Reply-To: ' . $senderName .'<'. $senderAddress. '>' .
"\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: PostOffice <postoffice@xxxxxxxxxxxxxx>' . "\r\n";
$headers .= 'From: ' . $senderName . '<' . $senderAddress . '>' .
"\r\n";

ini_restore(sendmail_from);
return $headers;
}

Any help is greatly appreceated.

Matthias


.



Relevant Pages

  • Re: [PHP] Beginner Questions regarding Mail and Forms
    ... parameter is disabled in SAFE MODE. ... but the var $age contains always an empty string. ... my guess is your form element name and post array key are not identical. ...
    (php.general)
  • Re: Do children learn language more easily?
    ... It appears that it's not a matter of a single switch being switched off all ... The language-learning device requires ... switching off even before age 1 if it it doesn't get it. ... are as successful in their language learning as children are. ...
    (sci.lang)
  • Re: Multiple IIFs - There has got to be a better way.
    ... Another option is the Switch function. ... A couple of points about the Age expression. ... Switch stops at the first test that evaluates to True. ... I have been using nested IIFs in my queries to accomplish this. ...
    (microsoft.public.access.gettingstarted)
  • Re: Interesting theory on dance
    ... to their age, so they switch and hide behind some other excuse. ... Hell, I even learned a new trick tonight while enjoying the rare pleasure of watching Maxwell Ho. ...
    (rec.arts.dance)
  • Re: Pet Cover?
    ... > almost 12 yrs now apparently limiting the ability to switch cover...or ... I doubt you will get the chance to change insurer at that age. ... I have just insured the new Rotty Pup with M&S, best deal around, with no ...
    (uk.rec.motorcycles)

Loading