-5

I have a contact form with drop downs, checkboxes and radio options but i can't make the checkboxes to be send to my email I tried this:

<label class="labelleft">¿Cómo se enteró de nosotros?</label>
        <label class="labelright"><input type="checkbox" name="findout[]" value="Email" />Email</label>
        <label class="labelright"><input type="checkbox" name="findout[]" value="Buscador"/>Buscador</label>
        <label class="labelright"><input type="checkbox" name="findout[]" value="Revista"/>Revista</label>
        <label class="labelright"><input type="checkbox" name="findout[]" value="Expo"/>Expo</label>
        <label class="labelright"><input type="checkbox" name="findout[]" value="Redes Sociales"/>Redes Sociales</label>

Im using this:

<form id="form1" name="form1" method="post" action="enviar.php">

and the php is:

<?php 
$mail='mail@mail.com'; 

$name = $_POST['name']; 
$email= $_POST['email'];
$phone = $_POST['phone'];
$giro = $_POST['giro'];
$negocio = $_POST['negocio'];
$dist = $_POST['dist'];
$findout = $_POST['findout'];
$rb= $_POST ['rbtn'];
$message = $_POST['message']; 
$thank="gracias.html"; 
$message = " 
Nombre: " .$name." 
Correo Electronico: " .$email." 
Telefono: " .$phone." 
Compania: " .$giro." $rb
Tipo de Negocio: ".$negocio."
Distribuidor: ".$dist."
Se entero: ".$findout."
Mensaje: " .$message."
"; 

if (mail($mail,"NIBO",$message)) 
Header ("Location: $thank"); 

?>

I just posted the html part of the checkboxes. When i send the email all im getting is the word "Array"

Not 100% sure what im doing wrong. Thanks in advance for any help or tips!

hachipark
  • 3
  • 4
  • 1
    You could use a `foreach` for your checkboxes. I.e.: `foreach($_POST['findout'] as $check){echo $check;}` – Funk Forty Niner Jul 22 '14 at 15:54
  • `$findout` is an array of checked values. You need to use something like `implode(',', $findout)` to get a string you can use in your email. – Stefan Jul 22 '14 at 19:16

2 Answers2

3

Using the foo[] naming hack in PHP causes foo to be an array in $_POST. Since you're just directly copying that array to a variable:

$foo = $_POST['foo'];

and then embedding that var in your email, you'll just get

Se entero: Array

in your email. You'll have to do something like:

$foo = implode(',', $_POST['foo']);

to convert the array into a plain string.

Marc B
  • 356,200
  • 43
  • 426
  • 500
0
$findout = $_POST['findout'];

Is an array of singular values you need to loop through them to get each value

$findout = "";
foreach($_POST['findout'] as $findout){
   $findout .= "{$findout} ";
}
$findout = rtrim($findout);

Then format your string depending on how you want it to look

James McClelland
  • 555
  • 4
  • 16