Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 17th, 2005, 06:43 AM
SJG
Guest
 
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
  #2  
Old July 17th, 2005, 06:43 AM
Julien CROUZET aka c2c
Guest
 
Posts: n/a
Default 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
  #3  
Old July 17th, 2005, 06:43 AM
Pedro Graca
Guest
 
Posts: n/a
Default 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 :
  #4  
Old July 17th, 2005, 06:43 AM
Marian Heddesheimer
Guest
 
Posts: n/a
Default 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
  #5  
Old July 17th, 2005, 06:43 AM
nice.guy.nige
Guest
 
Posts: n/a
Default 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!


 

Bookmarks

Thread Tools

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

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles