Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/07/2008, 13:18
Avatar de fakulicious
fakulicious
 
Fecha de Ingreso: mayo-2008
Ubicación: Mendoza
Mensajes: 140
Antigüedad: 16 años
Puntos: 2
Exclamación Pasar código HTML por un formulario en método POST

Hola, como va? En realidad, no sabía si ponerlo en este foro o en el de HTML, asique lo voy a postear en los dos..

El tema es que estoy haciendo un pequeño sistema de envío de e-mails a los usuarios registrados en mi base de datos.. Hice un formulario en el que pongo el Asunto y el Mensaje (que es un código HTML, ya que los mensajes se envían en ese formato)..

Todo funciona a la perfección, el problema que tengo es que el formulario no me pasa bien el código HTML del mensaje al archivo .php que ejecuta el script de envío.. Y si directamente le pongo el código HTML dentro del script, se envía perfectamente... pero no cuando lo paso desde un formulario...

alguien sabe como solucionar este problema?

Adjunto el código HTML del formulario y el PHP del script para que me digan si hay algún error..

Formulario:
Código HTML:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<style type="text/css">
<!--
.Estilo1 {
	font-family: Arial, Helvetica, sans-serif;
	font-weight: bold;
}
.Estilo2 {font-family: Arial, Helvetica, sans-serif}
.Estilo3 {
	font-family: Arial, Helvetica, sans-serif;
	color: #006600;
	font-weight: bold;
}
.Estilo4 {
	font-family: Arial, Helvetica, sans-serif;
	color: #FF0000;
	font-weight: bold;
}
-->
</style>
</head>

<body>
<p class="Estilo1">Formulario de Envio de Correo de Noticias</p>
<form id="form1" name="form1" method="post" action="enviar.php">
  <table width="541" border="0">
    <tr>
      <td width="123" height="38" class="Estilo2">Enviar desde </td>
      <td width="408"><label>
        <select name="desde" id="desde" tabindex="1">
          <option selected="selected">Seleccionar</option>
          <option value="OVS Risk Management &lt;[email protected]&gt;">Newsletter</option>
        </select>
      </label></td>
    </tr>
    <tr>
      <td height="39" class="Estilo2">Tipo</td>
      <td><label>
        <select name="tipo" id="tipo" tabindex="2">
          <option value="Content-type: text/html">HTML</option>
          <option value="Content-type: text">Texto</option>
        </select>
      </label></td>
    </tr>
    <tr>
      <td height="38" class="Estilo2">Asunto</td>
      <td><label>
        <input name="asunto" type="text" id="asunto" tabindex="3" size="50" />
      </label></td>
    </tr>
    <tr>
      <td height="35" valign="bottom" class="Estilo2">Mensaje</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2"><label>
        <textarea name="mensaje" cols="85" rows="20" id="mensaje" tabindex="4"></textarea>
      </label></td>
    </tr>
    <tr>
      <td height="41" colspan="2" align="center"><label>
        <input type="submit" name="Submit" value="Iniciar Env&iacute;o" tabindex="5" />
      </label></td>
    </tr>
  </table>
  </form>
<p>&nbsp;</p>
</body>
</html> 

Script PHP
Código PHP:
<html>
<head>
<style type="text/css">
<!--
.Estilo1 {
    font-family: Arial, Helvetica, sans-serif;
    font-weight: bold;
}
.Estilo2 {font-family: Arial, Helvetica, sans-serif}
.Estilo3 {
    font-family: Arial, Helvetica, sans-serif;
    color: #006600;
    font-weight: bold;
}
.Estilo4 {
    font-family: Arial, Helvetica, sans-serif;
    color: #FF0000;
    font-weight: bold;
}
-->
</style>
</head>
<body>

<?php

$from 
$_POST['desde'];
$tipo $_POST['tipo'];
$asunto $_POST['asunto'];
$mensaje $_POST['mensaje'];



include (
"conectar.php");

$result mysql_query("SELECT nombre, apellido, email, telefono, domicilio FROM registros"$coneccion);

echo 
'<table width="550" border = "0" cellspacing="2">
    <tr>
        <td width="250" height="29" bgcolor="#CCCCCC"><span class="Estilo1">Nombre</span></td>
        <td width="200" bgcolor="#CCCCCC"><span class="Estilo1">E-Mail</span></td>
        <td width="100" bgcolor="#CCCCCC"><span class="Estilo1">Resultado</span></td>
    </tr>'
;

while (
$row mysql_fetch_row($result)){

    
$nombre $row[0];
    
$apellido $row[1];
    
$to $row[2];
    
    
$headers "$tipo\r\n";
    
$headers .= "From: $from\n";
    
$headers .= "To: $nombre $apellido <$to>";

    
$enviar mail($to$asunto$mensaje$headers);

    if (
$enviar == 1) {

    echo 
'<tr>
        <td><span class="Estilo2">'
.$row[0].'&nbsp;'.$row[1].'</span></td>
        <td><span class="Estilo2">'
.$row[2].'</span></td>
        <td><p class="Estilo3">Enviado</p></td>
    </tr>'
;
    } else {
    
    echo 
'<tr>
        <td><span class="Estilo2">'
.$row[0].'&nbsp;'.$row[1].'</span></td>
        <td><span class="Estilo2">'
.$row[2].'</span></td>
        <td><p class="Estilo4">No enviado</p></td>
    </tr>'
;
    }

}

echo 
"</table>";

?>

</body>

</html>


Mensaje HTML:
Código HTML:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<style type="text/css">
<!--
.Estilo1 {
	font-family: Arial, Helvetica, sans-serif;
	color: #FFFFFF;
	font-weight: bold;
}
.Estilo2 {font-family: Arial, Helvetica, sans-serif}
-->
</style>
</head>

<body>
<table width="518" border="0">
  <tr>
    <td height="43" colspan="2" bgcolor="#0000FF"><div align="center" class="Estilo1">
      <p><img src="http://www.ovsrm.com.ar/img/logo.jpg" width="185" height="62" /></p>
      <p class="Estilo1">Mensaje Enviado desde Envio Masivo de OVS Risk Management  </p>
    </div></td>
  </tr>
  <tr>
    <td colspan="2"><p class="Estilo2">Buenas tardes, <strong>'.$row [0].'</strong></p>
      <p class="Estilo2">Este es un Mensaje de Prueba del sistema de Env&iacute;o Masivo de Correo Electr&oacute;nico para nuestros usuarios.</p>
      <p class="Estilo2">Su nombre completo es <strong>'.$row[0].' '.$row[1].'</strong></p>
      <p class="Estilo2">Su direcci&oacute;n de Correo Electr&oacute;nico es <strong>'.$row[2].'</strong></p>
      <p class="Estilo2">Su n&uacute;mero telef&oacute;nico es <strong>'.$row[3].'</strong></p>
      <p><span class="Estilo2">Su domicilio es <strong>'.$row[4].'</strong></span></p>
      <p>&nbsp;</p>
      <p><img src="http://www.ovsrm.com.ar/img/logo.jpg" width="185" height="62" /></p>
    <p><strong>Carlos Valentini</strong></p> </td>
  </tr>
</table>
</body>
</html> 


Muchisimas gracias!



fakulicious!*