Forum Moderators: coopster

Message Too Old, No Replies

populating an array

how do I populate an array with specific variables?

         

Mitch888

5:21 pm on Mar 12, 2003 (gmt 0)

10+ Year Member



hi,
I need to email a php form to me. I got the form to work, however, the email is blank.

I do not know how to put the $msg_body into array. I need to email the following variables:

$name
$email
$Dogname
$city

how do I populate the array ($msg_body) with the above variables.

I am using this script to send the mail:

$message = "";
$message .= "$msg_body";
$subject = "Register your dog";
$thisemail = "myemail@mydomain.com";

$headers = "From: dogy pics<myemail@mydomain.com>\n";
$headers .= "X-Sender: <myemail@mydomain.com>\n";
$headers .= "X-Mailer: PHP\n"; //mailer
$headers .= "X-Priority: 1\n"; //1 UrgentMessage, 3 Normal
$headers .= "Return-Path: <myemail@mydomain.com>\n";

mail($thisemail, "$subject", "$msg_body",$headers);

thank you

andreasfriedrich

5:39 pm on Mar 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



mail() [php.net] does not expect an array as its third parameter. You should use a plain string. To build your message string use either the concatenation operator (.), variable interpolation or sprintf() [php.net]. There is no need to enclose variables that you want to pass to mail() [php.net] in double quotes.

To send $dogname, $catname, and $fishname to $petowner you would use code like this:


mail [php.net]($petowner,
"A message regarding $dogname, $catname, and $fishname",
$dogname . $catname . $fishname,
"From: Your Turtle <turtle@airboy.com>\n\r");

or


mail [php.net]($petowner,
"A message regarding $dogname, $catname, and $fishname",
sprintf [php.net]("Name of your dog: %s\nName of your cat: %s\nName of your fish: %s",
$dogname, $catname, $fishname),
"From: Your Turtle <turtle@airboy.com>\n\r");

HTH Andreas

jatar_k

5:40 pm on Mar 12, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you can't slap an array into the message like that.

try
$message = $name . "\r\n" . $email . "\r\n" . $Dogname . "\r\n" . $city;

then
mail($thisemail,$subject,$message,$headers);

Mitch888

6:45 pm on Mar 12, 2003 (gmt 0)

10+ Year Member



i will try.

Mitch888

6:02 am on Mar 18, 2003 (gmt 0)

10+ Year Member



it worked :)

thank you