Connecting Tech Pros Worldwide Forums | Help | Site Map

Mail Function & Multiple form fields

SJG
Guest
 
Posts: n/a
#1: Jul 17 '05
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

Julien CROUZET aka c2c
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Mail Function & Multiple form fields


stuart@sjgill.force9.net (SJG) pipotte et a dit :
[color=blue]
> 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?
>[/color]

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

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

--
Julien CROUZET aka c2c Promo 2007[color=blue]
> Et les news sont un coin sympa pour discuter,
> un peu comme le cafe du coin[/color]
Chichery Florent
Pedro Graca
Guest
 
Posts: n/a
#3: Jul 17 '05

re: Mail Function & Multiple form fields


SJG wrote:[color=blue]
> 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";[/color]

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

$message .= "Company: ".$strCompany."\r\n";
[color=blue]
> 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?[/color]

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 :
Marian Heddesheimer
Guest
 
Posts: n/a
#4: Jul 17 '05

re: Mail Function & Multiple form fields


On 9 Jun 2004 01:13:22 -0700, stuart@sjgill.force9.net (SJG) wrote:
[color=blue]
>$message = "Name: ".$strName."\r\n";
>"Company: ".$strCompany."\r\n";[/color]

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
nice.guy.nige
Guest
 
Posts: n/a
#5: Jul 17 '05

re: Mail Function & Multiple form fields


While the city slept, SJG <stuart@sjgill.force9.net> feverishly typed:
[color=blue]
> 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.[/color]

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!


Closed Thread


Similar PHP bytes