Re: [PHP] Beginner Questions regarding Mail and Forms

2007-02-12 Thread Jochem Maas
Matthias S. wrote:
> hi jochem,
> 
> thanks. i've tripplechecked on the names, but just in case I miss something

don't just read the code - run it with suitable var_dump() statements and
view the output to determine what is *really* happening.

2 possiblities/probabilities:

1. your misspelling the post var name.
2. the invalid html is causing the 'age' post var not to be sent at all.

in either case a suitable var_dump() will shed light.


> obvious, I'll post the entire snippets.
> 
...  ...

> mail("[EMAIL PROTECTED]", "Request", $message, _getMailHeaders($name, 
> §email));
> }
> catch(Exception $e)
> {
> ...
> }

try/catch here does *nothing* for you - php function do not issue exceptions, 
the only things that
issue exceptions are some of the new[er] object interfaces in extensions like 
tidy, spl & simplexml (IIRC)
and userland code that you (or a third party) are explicitly throwing at some 
point in the code.

mail() will only ever emit errors.

it can be a PITA but such is life; php has 2 'error paradigms':

1. std (old school) php errors (see 
http://php.net/manual/en/function.set-error-handler.php).
2. exceptions.

they are mutually exclusive, pretty much, and you'll have to take account for 
both.

PS - always check the english version of the manual as well as you 
local-language version- the
english version is often more up to date.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Beginner Questions regarding Mail and Forms

2007-02-12 Thread Edward Kay
> > Age Alter:
> > 
> >

Sorry - I was a bit too hasty with the send button. I've just seen that
you've also changed the name in the script too.

I also see that you have a semi-colon outside the style attribute. I don't
think this will help matters. Get your HTML to validate and that will
probably fix the problem.

Edward

> There's your problem: name="txtAge". For your PHP script to work
> you need name="_txtAge".
>
> PS: You should also have quotes around the 50 in the maxlength attribute.
>
> Edward

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Beginner Questions regarding Mail and Forms

2007-02-12 Thread Németh Zoltán
On h, 2007-02-12 at 14:09 +, Edward Kay wrote:
> > Age Alter:
> > 
> >
> 
> There's your problem: name="txtAge". For your PHP script to work you need
> name="_txtAge".

in his last email the OP has the name "txtAge" in his php script also...

greets
Zoltán Németh

> 
> PS: You should also have quotes around the 50 in the maxlength attribute.
> 
> Edward
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Beginner Questions regarding Mail and Forms

2007-02-12 Thread Edward Kay
> Age Alter:
> 
>

There's your problem: name="txtAge". For your PHP script to work you need
name="_txtAge".

PS: You should also have quotes around the 50 in the maxlength attribute.

Edward

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Beginner Questions regarding Mail and Forms

2007-02-12 Thread Németh Zoltán
On h, 2007-02-12 at 14:54 +0100, Matthias S. wrote:
> hi jochem,
> 
> thanks. i've tripplechecked on the names, but just in case I miss something
> obvious, I'll post the entire snippets.
> 
> +++ HTML form +++
> 
> 
> 
> Name Name:
> 
> 
> Email-Address E-Mail
> Adresse:
> 
> 
> Age Alter:
> 

I'm not sure but this ; at the end of the line may cause troubles

the line should be correctly:


greets
Zoltán Németh

> 
> Gender  class="translate">Geschlecht:
> 
> female | weiblich
> male | mnnlich
> 
> 
> Anything more to say? Noch
> ein Kommentar?
> 
> 
> 
> 
> 
> 
> 
> 
> +++
> +++ PHP file +++
> $name = $_POST['_txtName'];
> $email = $_POST['_txtEmail'];
> $age = $_POST['txtAge'];
> $gender = $_POST['_optGender'];
> $info = $_POST['_txtInfo'];
> 
> $message = "Name: " . $name . "\n";
> $message .= "Email: " .$email . "\n";
> $message .= "Age: " . $age . "\n";
> $message .= "Gender: " . $gender . "\n";
> $message .= "Info: " . $info;
> try {
> mail("[EMAIL PROTECTED]", "Request", $message, _getMailHeaders($name, email));
> }
> catch(Exception $e)
> {
> ...
> }
> +++
> 
> 
> "Jochem Maas" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
> news:[EMAIL PROTECTED]
> > 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.
> >
> > which another way of saying 'my hosting env sucks' - but that's besides
> the point.
> > (short story: 'safe mode' isn't)
> >
> > >
> > > 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.
> > >
> > > Can you help? I'm a programmer (C++)
> >
> > so the concept of debugging code should not be new to you.
> > so hello to print_r(), var_dump() and echo - they are your friends.
> >
> > e.g. stick the following at the top of your script (to start with):
> >
> > var_dump(
> > $_POST['_txtAge'],
> > $_POST
> > );
> >
> > my guess is your form element name and post array key are not identical.
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Beginner Questions regarding Mail and Forms

2007-02-12 Thread Matthias S.
hi jochem,

thanks. i've tripplechecked on the names, but just in case I miss something
obvious, I'll post the entire snippets.

+++ HTML form +++



Name Name:


Email-Address E-Mail
Adresse:


Age Alter:


Gender Geschlecht:

female | weiblich
male | mÃnnlich


Anything more to say? Noch
ein Kommentar?








+++
+++ PHP file +++
$name = $_POST['_txtName'];
$email = $_POST['_txtEmail'];
$age = $_POST['txtAge'];
$gender = $_POST['_optGender'];
$info = $_POST['_txtInfo'];

$message = "Name: " . $name . "\n";
$message .= "Email: " .$email . "\n";
$message .= "Age: " . $age . "\n";
$message .= "Gender: " . $gender . "\n";
$message .= "Info: " . $info;
try {
mail("[EMAIL PROTECTED]", "Request", $message, _getMailHeaders($name, §email));
}
catch(Exception $e)
{
...
}
+++


"Jochem Maas" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
> 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.
>
> which another way of saying 'my hosting env sucks' - but that's besides
the point.
> (short story: 'safe mode' isn't)
>
> >
> > 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.
> >
> > Can you help? I'm a programmer (C++)
>
> so the concept of debugging code should not be new to you.
> so hello to print_r(), var_dump() and echo - they are your friends.
>
> e.g. stick the following at the top of your script (to start with):
>
> var_dump(
> $_POST['_txtAge'],
> $_POST
> );
>
> my guess is your form element name and post array key are not identical.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Beginner Questions regarding Mail and Forms

2007-02-12 Thread Németh Zoltán
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" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
> news:[EMAIL PROTECTED]
> > 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("[EMAIL PROTECTED]", "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 <[EMAIL PROTECTED]>' . "\r\n";
> > >  $headers .= 'From: ' . $senderName . '<' . $senderAddress . '>' .
> "\r\n";
> > >
> > >  ini_restore(sendmail_from);
> > >  return $headers;
> > > }
> > >
> > > Any help is greatly appreceated.
> > >
> > > Matthias
> > >
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Beginner Questions regarding Mail and Forms

2007-02-12 Thread Jochem Maas
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.

which another way of saying 'my hosting env sucks' - but that's besides the 
point.
(short story: 'safe mode' isn't)

> 
> 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.
> 
> Can you help? I'm a programmer (C++)

so the concept of debugging code should not be new to you.
so hello to print_r(), var_dump() and echo - they are your friends.

e.g. stick the following at the top of your script (to start with):

var_dump(
$_POST['_txtAge'],
$_POST
);

my guess is your form element name and post array key are not identical.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Beginner Questions regarding Mail and Forms

2007-02-12 Thread Matthias S.
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.

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.

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

"Németh Zoltán" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
> 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("[EMAIL PROTECTED]", "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
> Zoltán Németh
>
> >
> > 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 <[EMAIL PROTECTED]>' . "\r\n";
> >  $headers .= 'From: ' . $senderName . '<' . $senderAddress . '>' .
"\r\n";
> >
> >  ini_restore(sendmail_from);
> >  return $headers;
> > }
> >
> > Any help is greatly appreceated.
> >
> > Matthias
> >

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Beginner Questions regarding Mail and Forms

2007-02-12 Thread Németh Zoltán
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("[EMAIL PROTECTED]", "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
Zoltán Németh

> 
> 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 <[EMAIL PROTECTED]>' . "\r\n";
>  $headers .= 'From: ' . $senderName . '<' . $senderAddress . '>' . "\r\n";
> 
>  ini_restore(sendmail_from);
>  return $headers;
> }
> 
> Any help is greatly appreceated.
> 
> Matthias
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php