Remove this line
$catalogs = print_r( $catalogsa, true );
Then do
$msg .= "Catalogs:\r";
foreach($catalogsa as $catalog)
{
$msg .= $catalog . "\r";
}
質問
I am not a PHP guy so forgive me if this is something basic.
Here are my three checkboxes on the HTML page:
<INPUT TYPE="CHECKBOX" NAME="box[]" CLASS="box[]" VALUE="Communication Products Catalog">
<INPUT TYPE="CHECKBOX" NAME="box[]" CLASS="box[]" VALUE="Optics Catalog">
<INPUT TYPE="CHECKBOX" NAME="box[]" CLASS="box[]" VALUE="Systems Products Catalog">
When I hit submit I have a single php script that just grabs the values of all fields, throws them into a variable and then I use the mail function to send it out.
Here is where I pull the values from the form in my php script:
$firstname = $_REQUEST['firstname'] ;
$lastname = $_REQUEST['lastname'] ;
$company = $_REQUEST['company'] ;
$email = $_REQUEST['email'] ;
$phone = $_REQUEST['phone'] ;
$addr = $_REQUEST['addr'] ;
$city = $_REQUEST['city'] ;
$state = $_REQUEST['state'] ;
$zip = $_REQUEST['zip'] ;
$catalogsa = $_REQUEST['box'] ;
$catalogs = print_r( $catalogsa, true );
And finally I "compile" the $msg var which makes up the body of the email:
$msg = "First Name:\t$firstname\r";
$msg .= "Last Name:\t$lastname\r";
$msg .= "Company:\t$company\r";
$msg .= "Email:\t\t$email\r";
$msg .= "Phone:\t\t$phone\r";
$msg .= "Address:\t$addr\r";
$msg .= "City:\t\t$city\r";
$msg .= "State:\t\t$state\r";
$msg .= "Zip Code:\t$zip\r\r";
$msg .= "Catalogs:\r$catalogs\r";
All of this works and the body of the email does only contain the value of the CHECKED boxes. But this is what it looks like when I get the email.....
First Name: ME
Last Name: MYSELF
Company: AND I INC
Email: NONE@NONE.COM
Phone: 111-111-1111
Address: 222 SOME ST
City: SOME TOWN
State: NY
Zip Code: 11777
Catalogs:
Array
(
[0] => Communication Products Catalog
[1] => Systems Products Catalog
)
I'm looking for a way to clean up the $catalogs variable so it would just look like:
Communication Products Catalog
Systems Products Catalog
Thanks in advance,
Kenny
解決
Remove this line
$catalogs = print_r( $catalogsa, true );
Then do
$msg .= "Catalogs:\r";
foreach($catalogsa as $catalog)
{
$msg .= $catalog . "\r";
}
他のヒント
May be this can help you
$firstname = $_REQUEST['firstname'] ;
$lastname = $_REQUEST['lastname'] ;
$company = $_REQUEST['company'] ;
$email = $_REQUEST['email'] ;
$phone = $_REQUEST['phone'] ;
$addr = $_REQUEST['addr'] ;
$city = $_REQUEST['city'] ;
$state = $_REQUEST['state'] ;
$zip = $_REQUEST['zip'] ;
$catalogsa = $_REQUEST['box'] ;
if(sizeof($catalogsa)>0){
$catalogs = implode(",",$catalogsa);
}
You can user comma(,) or a new line ("<br/>"). Let me know if it solves your problem.
$msg .= "Catalogs:";
foreach ($catalogsa as $catalog){
$msg .= $catalog."\r";
}
Remove $msg .= "Catalogs:\r$catalogs\r";
and $catalogs = print_r($catalogsa, true);
try with this :
foreach($catalogsa as $catalog) {
$msg .= "Catalog:\r$catalog\r";
}
So it will out out this:
Catalog: Communication Products Catalog
Catalog: Systems Products Catalog