Ver Mensaje Individual
  #5 (permalink)  
Antiguo 08/07/2008, 15:02
Avatar de fakulicious
fakulicious
 
Fecha de Ingreso: mayo-2008
Ubicación: Mendoza
Mensajes: 140
Antigüedad: 16 años
Puntos: 2
Exclamación Respuesta: Como enviar mails en formato HTML desde un formulario

Gracias.. funcionó perfectamente eso.. agregué stripslashes(); y me envía el mensaje HTML a la perfección..

El tema ahora es que no me toma las variables.. Me toma las variables como texto..

Me llega así:

Buenas tardes, '.$row[0].'

cuando debería mostrarme

Buenas tardes, Carlos

yo creo que el problema está porque si yo tendría el contenido de la variable directamente dentro des script se daría así:

Código PHP:
$mensaje '<p>Buenas tardes, <b>'.$row[0].'</b></p>'
pero al tenerla así:

Código PHP:
$mensaje $_POST['mensaje']; 
no puedo definirle que comience con ' y termine con '; entonces no me "suma" las variables, sino que interpreta que las ' son parte del texto..

Pongo todo el script para ver si alguien me dice como puedo solucionarlo..

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'];

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)){

    
$mensaje stripslashes($_POST['mensaje']);
    
$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>

Muchas gracias!

fakulicious!*