Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/09/2007, 13:02
miczoe
 
Fecha de Ingreso: noviembre-2006
Mensajes: 102
Antigüedad: 17 años, 5 meses
Puntos: 0
Como pasar variable a input? name="destino"

No puedo hacer que me tome los mails del campo de la bd users campo nick.


Código PHP:
<?php 
include('config.php');
$x=0// Asigamos una variable temporal, llamemosle "x"
$user mysql_query("SELECT * FROM users WHERE lista='Si'"); // Query a la bdd coje los usuarios
                                                                    // que la tienen activada
while ($row mysql_fetch_array($user)) { $a "$a$row[nick], "$x++; }


echo
'<form action="mail.php" method="post" enctype="multipart/form-data">
   <input type="text" name="destino" value=$a;><br>
 <input type="text" name="asunto"><br>
   <input type="file" name="archivo"><br>
<textarea name="mensaje"></textarea><br>
<input type="submit" name="action" value="send">
 </form>'
;

require(
"class.phpmailer.php");
 
      if (
$_POST['action'] == "send") {
 
          
$varname $_FILES['archivo']['name'];
 
          
$vartemp $_FILES['archivo']['tmp_name'];

         

          
$mail = new PHPMailer();
 
          
$mail->Host "localhost";
  
          
$mail->From "[email protected]";
 
          
$mail->FromName "Z";

          
$mail->Subject $_POST['asunto'];

          
$mail->AddAddress($_POST['destino']);

          if (
$varname != "") {
  
              
$mail->AddAttachment($vartemp$varname);
 
          }

          
$body "<strong>Mensaje</strong><br><br>";
 
          
$body.= $_POST['mensaje']."<br>";

          
$body.= "<i>Enviado por http://www.domain.com.ar</i>";

          
$mail->Body $body;

          
$mail->IsHTML(true);

          
$mail->Send();

      }


if(!
$mail)
{
echo 
"Problemas enviando correo electrónico a ".$valor;
echo 
"<br>".$mail->ErrorInfo;
}
else
{
echo 
"Mensaje enviado correctamente";
}
?>

Última edición por miczoe; 30/09/2007 a las 11:46