Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/10/2012, 21:32
dcenteno1
 
Fecha de Ingreso: abril-2009
Mensajes: 5
Antigüedad: 15 años
Puntos: 0
Información formulario a varios correos con checkbox

buenas noches amigos, tengo una duda la cual requiero ayuda, resulta que en mi web estoy montando un formulario para correo electronico, el detalle es que estoy colocando unos checkbox los cuales cada uno indica un correo diferente al cual seran enviados los datos, lo que quiero es que solo se envie el correo a los checkbox que estan marcados, les mando un ejemplo de mi codigo...

contactalo.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CONTACTENOS</title>

</head>
<body>
<form id="contacto" name="contacto" method="post" action="kp-prueba.php">
<center><table width="100%" height="100%" border="0">
<tr>
<td width="888" height="248"><CENTER>
<p>&nbsp;</p>
<p>&nbsp;</p>
<table width="500" height="222" border="0" align="center" cellpadding="0" cellspacing="0" style="background-color:transparent">
<tr>
<td colspan="3" align="left"><strong class="Estilo9"><em><font style="font-size:20px">Consultas e Inquietudes:</font></em></strong></td>
</tr>

<tr>
<td width="18" height="32">&nbsp;</td>
<td width="119"><em><font style="font-size:16px">Nombre:</font></em><br>
&nbsp;</td>
<td width="363" align="left"><label><input type="text" name="nombre" id="nombre" maxlength="30"/></label><br>
&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><em><font style="font-size:16px">Apellido:</font></em><br>
&nbsp;</td>
<td align="left"><label><input type="text" name="apellido" id="apellido" maxlength="30"/></label><br>
&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><em><font style="font-size:16px">Teléfono:</font></em><br>
&nbsp;</td>
<td align="left"><label><input type="text" name="tlf" id="tlf" maxlength="15"/></label><br>
&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><em><font style="font-size:16px">E-mail:</font></em><br>
&nbsp;</td>
<td align="left"><label><input type="text" name="mail" id="mail"/></label><br>
&nbsp;</td>
</tr>
</table>
<input type="checkbox" name="cor1" /> correo1<br>
<input type="checkbox" name="cor2" /> correo2<br>
<input type="checkbox" name="cor3" /> correo3<br>
<p>&nbsp;</p>
<table width="500" height="159" border="0" align="center" cellpadding="0" cellspacing="0" style="background-color:transparent">
<tr>
<td align="left"><strong class="Estilo9"><em><font style="font-size:20px">Déjenos un Mensaje:</font></em></strong></td>
</tr>
<tr>
<td align="center"><p>
<label><textarea name="mensaje" id="mensaje"></textarea></label>
</p></td>
</tr>
<tr>
<td align="center"><input type="submit" name="OK" value="Enviar" onclick="alert('Su mensaje fue enviado Satisfactoriamente...')"/></td>
</tr>
</table>
<p>&nbsp;</p>
</CENTER>
</td>
</tr>
</table></center>
</form>
</body>
</html>


----------------------------------------------------------------------------------------------------


y aqui esta el que es llamado...

kp-prueba.php

<?php

$nombre = $_POST['nombre'];
$apellido = $_POST['apellido'];
$tlf = $_POST['tlf'];
$mail = $_POST['mail'];
$cor1 = $_POST['correo1'];
$cor2 = $_POST['correo2'];
$cor3 = $_POST['correo3'];

$header = 'From: ' . $mail . " \r\n";
$header .= "X-Mailer: PHP/" . phpversion() . " \r\n";
$header .= "Mime-Version: 1.0 \r\n";
$header .= "Content-Type: text/plain";

$mensaje .= "Este mensaje fue enviado por: \r\n\n";
$mensaje .= "Nombre: " . $nombre . " \r\n";
$mensaje .= "Apellido: " . $apellido . " \r\n";
$mensaje .= "Telefono: " . $tlf . " \r\n";
$mensaje .= "Su e-mail es: " . $mail . " \r\n";
$mensaje .= "Mensaje: " . $_POST['mensaje'] . " \r\n";
$mensaje .= "Enviado el: " . date('d/m/Y', time());

if ($OK == "Enviar") {

if ( $cor1 == "on" ){ $para = '[email protected]'; $asunto = 'Consulta'; };

if ( $cor2 == "on" ){ $para = '[email protected]'; $asunto = 'Consulta'; };

if ( $cor3 == "on" ){ $para = '[email protected]'; $asunto = 'Consulta'; };

};


mail($para, $asunto, utf8_decode($mensaje), $header);
echo "<script>document.location.href='contactalo.ph p';</script>\n";

?>