By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,278 Members | 1,342 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,278 IT Pros & Developers. It's quick & easy.

Mail Function & Multiple form fields

P: n/a
SJG
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
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
st****@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
Jul 17 '05 #2

P: n/a
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 :
Jul 17 '05 #3

P: n/a
On 9 Jun 2004 01:13:22 -0700, st****@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:ma****@heddesheimer.de
http://www.rent-a-tutor.com Software on the Web
Jul 17 '05 #4

P: n/a
While the city slept, SJG <st****@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. ni***@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!
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.