Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/11/2008, 12:14
ferchackal
 
Fecha de Ingreso: noviembre-2008
Mensajes: 18
Antigüedad: 15 años, 5 meses
Puntos: 0
variables de checkbox y mandar mails

Buenas!!!
estoy trabado con un especie de programita que estaba armando en PHP, la idea es que el que lo use escriba los datos como para mandar un newsletter en un formato en html y pueda cargar los destinatarios.
tengo 2 problemas que no puedo resolver
1) me aparecen ciertos datos de la base de datos como ser el nombre del destinatario y el email del mismo con un checkbox al lado, lo que yo quiero es que al tildar ese checkbox me pase esa info al php siguiente al cual manda el form
2) en el 2do php el cual se encarga de mandar los mails quiero que se me manden automatico con un bucle while (creo no se muy bien) a los que había seleccionado el checkbox en la parte anterior.

el script de la primer parte es el siguiente:

<table width="750" border="0" align="center" style="margin-top:30px">
<tr>
<td><table width="750px" border="0">
<tr>
<td><table width="746px" border="0" cellspacing="0" align="center">
<tr bgcolor="#345D93">
<td>
<FORM id="form1" name="form1" ACTION="enviodemails.php" method="post">
<?php
$result=mysql_query("select * from eng_clientes",$link);
?>
<table width="720px" border="0" align="center" class="Estilo2">
<tr>
<td colspan="4"><strong>Seleccione los destinatario a los cuales desea enviar el e-mail</strong></td>
</tr>
<TR>
<TD><B>ID</B></TD>
<TD><B>Nombre</B>&nbsp; </TD>
<TD><B>Email</B>&nbsp;</TD>
<TD><B>Enviar
<label></label>
</B>&nbsp;</TD>
</TR>
<TR>
<?php
while($row = mysql_fetch_array($result)) {
printf("<tr><td>&nbsp;%s</td> <td>&nbsp;%s</td> <td>&nbsp;%s</td> <td><input type='checkbox' name='opcion[$id]' value='[$id]' /></td></tr>", $row["id"], $row["nombre"], $row["email"], $row["id"]);
}
?>
</TR>
<TR>
<TD colspan="4" align="right" style="padding-top:10px"><input type="hidden" name="remitentedelmail" value="<?php echo $_POST['remitentedelmail'];?>" id="remitentedelmail" size="40" />
<input type="hidden" name="asuntodelmail" value="<?php echo $_POST['asuntodelmail'];?>" id="asuntodelmail" size="40" />
<input type="hidden" name="cuerpodelmail" value="<?php echo $_POST['cuerpodelmail'];?>" id="cuerpodelmail" size="40" />
<input type="hidden" name="sunombredelmail" value="<?php echo $_POST['sunombredelmail'];?>" id="sunombredelmail" size="40" />
<input type="button" name="seleccionar" value="Seleccionar Todos" onclick="marcar(1,this.form)" id="seleccionar" />
<input type="button" name="desmarcar" value="Desmarcar Todos" onclick="marcar(0,this.form)" id="desmarcar" />
<input name="enviar" type="submit" value="Enviar Emails" id="enviar" /></TD>

</TR>
</table>
</FORM></td>
</tr>


</table></td>
</tr>
</table></td>
</tr>

</table>
</body>
</html>

y el segundo php, en enviodemails.php es:

<?
$variable1= $_POST['opcion'];
$remitentedelmail=$_POST['remitentedelmail'];
$asuntodelmail=$_POST['asuntodelmail'];
$sunombredelmail=$_POST['sunombredelmail'];
$cuerpodelmail=$_POST['cuerpodelmail'];
$destinatario = "[email protected]";
$asunto = $asuntodelmail;
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

$cuerpo = '
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>prueba</title>
<style type="text/css">
<!--
.Estilo1
{font-size: 16px;
font-family:Arial, Helvetica, sans-serif;
padding-top:20px;
}
.Estilo11
{font-size: 16px;
font-family:Arial, Helvetica, sans-serif;
}
.Estilo2
{font-size: 16px;
font-family:Arial, Helvetica, sans-serif;
padding-right:20px;
vertical-align:top;
}
.Estilo3
{font-size: 12px;
font-family:Arial, Helvetica, sans-serif;
}
.Estilo4
{font-size: 16px;
font-family:Arial, Helvetica, sans-serif;
text-align:right;
padding-right:20px;
}
A:link {
COLOR: #000000;
TEXT-DECORATION: none;
font-size: 12px;
font-family:Arial, Helvetica, sans-serif;
}
A:visited {
COLOR: #000000;
TEXT-DECORATION: none;
font-size: 12px;
font-family:Arial, Helvetica, sans-serif;
}
A:hover {
COLOR: #000000;
TEXT-DECORATION: none;
font-size: 12px;
font-family:Arial, Helvetica, sans-serif;
}
-->
</style>
</head>

<body>
<table width="750" border="0" align="center">
<tr>
<td><table width="750px" border="0">
<tr>
<td background="http://www.prueba.com/maileronline/titulo.jpg" height="120px">&nbsp;</td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="746px" border="0" cellspacing="0" align="center">
<tr bgcolor="#345D93" valign="top">
<td width="284" rowspan="4"><img src="http://www.prueba.com/maileronline/mundo.jpg" width="265" height="261" /></td>
<td class="Estilo1" valign="top">Estimado "Cliente"</td>

</tr>
<tr bgcolor="#345D93" valign="top">
<td width="456" valign="top" class="Estilo11">Ref: '.$asuntodelmail.'</td>
</tr>
<tr bgcolor="#345D93" valign="top">
<td class="Estilo2" valign="top">'.$cuerpodelmail.'</td>
</tr>

<tr bgcolor="#345D93">
<td class="Estilo4"><br>
Saludos Cordiales
<br>
prueba</br></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>

';


mail($destinatario,$asunto,$cuerpo,$headers)
?>

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

quiero que haga esta funcion mail para todos los checkbox tildados en la pagina anterior automaticamente, cambiando el destinatario y si es posible que también dentro del 'cuerpo' del html me inserte el nombre de cada cliente según el mail que se manda

si alguien me ayuda con esto es un genio! ja, me estoy volviendo loco
gracias!!