Mail Function & Multiple form fields

This is a discussion on Mail Function & Multiple form fields within the PHP Language forums, part of the PHP Programming Forums category; I'm having some problems with a php mail form where I am wanting to send information from 10 form ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-09-2004
SJG
 
Posts: n/a
Default Mail Function & Multiple form fields

I'm having some problems with a php mail form where I am wanting to
send information from 10 form fields in a e-mail. the way I have it
structured for the mail command is

mail ($to,$subject,$message);

where message is made up from the multiple fields from the form e.g

$message = "Name: ".$strName."\r\n";
"Company: ".$strCompany."\r\n";

The e-mail is sent fine but it only gives me the persons name and not
the extra fields.

Can anyone point me in the right direction?

thanks

Stuart
Reply With Quote
  #2 (permalink)  
Old 06-09-2004
Julien CROUZET aka c2c
 
Posts: n/a
Default Re: Mail Function & Multiple form fields

stuart@sjgill.force9.net (SJG) pipotte et a dit :

> I'm having some problems with a php mail form where I am wanting to
> send information from 10 form fields in a e-mail. the way I have it
> structured for the mail command is
>
> mail ($to,$subject,$message);
>
> where message is made up from the multiple fields from the form e.g
>
> $message = "Name: ".$strName."\r\n";
> "Company: ".$strCompany."\r\n";
>
> The e-mail is sent fine but it only gives me the persons name and not
> the extra fields.
>
> Can anyone point me in the right direction?
>


"Name:" and "Company :" should be placed in the $additional_headers
parameter.

mail($to, $subject, $message, $additional_headers);

--
Julien CROUZET aka c2c Promo 2007
> Et les news sont un coin sympa pour discuter,
> un peu comme le cafe du coin

Chichery Florent
Reply With Quote
  #3 (permalink)  
Old 06-09-2004
Pedro Graca
 
Posts: n/a
Default Re: Mail Function & Multiple form fields

SJG wrote:
> I'm having some problems with a php mail form where I am wanting to
> send information from 10 form fields in a e-mail. the way I have it
> structured for the mail command is
>
> mail ($to,$subject,$message);
>
> where message is made up from the multiple fields from the form e.g
>
> $message = "Name: ".$strName."\r\n";
> "Company: ".$strCompany."\r\n";


This line doesn't do anything!
I think maybe you want:

$message .= "Company: ".$strCompany."\r\n";

> The e-mail is sent fine but it only gives me the persons name and not
> the extra fields.
>
> Can anyone point me in the right direction?


You're not addind data to the $message variable.

--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Reply With Quote
  #4 (permalink)  
Old 06-09-2004
Marian Heddesheimer
 
Posts: n/a
Default Re: Mail Function & Multiple form fields

On 9 Jun 2004 01:13:22 -0700, stuart@sjgill.force9.net (SJG) wrote:

>$message = "Name: ".$strName."\r\n";
>"Company: ".$strCompany."\r\n";


you should use the point operator to concatenate the two together:

$message = "Name: ".$strName."\r\n" . "Company: ".$strCompany."\r\n";

Feel free to use my contact form generator at:

http://www.rent-a-tutor.com/tools/

to build an online form online. The PHP source will be sent to you via
e-mail, so make sure you enter a valid mail address.

After you received the code, you can check the source and find out how
I have done it :-)

Regards

Marian

--
http://www.heddesheimer.de mailto:marian@heddesheimer.de
http://www.rent-a-tutor.com Software on the Web
Reply With Quote
  #5 (permalink)  
Old 06-09-2004
nice.guy.nige
 
Posts: n/a
Default Re: Mail Function & Multiple form fields

While the city slept, SJG <stuart@sjgill.force9.net> feverishly typed:

> I'm having some problems with a php mail form where I am wanting to
> send information from 10 form fields in a e-mail. the way I have it
> structured for the mail command is
>
> mail ($to,$subject,$message);
>
> where message is made up from the multiple fields from the form e.g
>
> $message = "Name: ".$strName."\r\n";
> "Company: ".$strCompany."\r\n";
>
> The e-mail is sent fine but it only gives me the persons name and not
> the extra fields.


The semicolons at the end of each line terminate the line of code, so you
have a line of code that says $message = "Name: ".$strName."\r\n"; and
another which is the rather mysterious "Company: ".$strCompany."\r\n";
(though I would expect you to be getting an error message for that line).

As others have suggested, you can use
$message = "Name: ".$strName."\r\n"."Company: ".$strCompany."\r\n";

or,

$message = "Name: ".$strName."\r\n";
$message .= "Company: ".$strCompany."\r\n";

or you could use

$message = "Name: $strName\r\n
Company: $strCompany\r\n";

Hope that helps,
Nige

--
Nigel Moss.

Email address is not valid. nigel@nigenetDOG.org.uk. Take the dog out!
http://www.nigenet.org.uk | Boycott E$$O!! http://www.stopesso.com
In the land of the blind, the one-eyed man is very, very busy!


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 08:27 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0