Ver Mensaje Individual
  #2 (permalink)  
Antiguo 07/07/2010, 09:39
danielzam
 
Fecha de Ingreso: mayo-2008
Ubicación: Lima
Mensajes: 11
Antigüedad: 15 años, 10 meses
Puntos: 0
Respuesta: Envio de Mail HTML con consultas a una BD con PHP

Este es en otro archivo.

// email-form.php
<?php
include_once("inc/session.php"); // aca esta la conexion.


$ob = "";
if (isset($_GET['ob']))
{
$ob = $_GET['ob'];
}else{
$ob = "Pais";
}

if (isset($_GET['n']) && isset($_POST['Pais']) == false )
{
if ($n == 1)
{
$inicio = 0;
$fin = 25;
}else{
$inicio = $_GET['n'];
$fin = $inicio*25;
$inicio = ($inicio-1)*25;
}
}elseif(isset($_POST['Pais']) == false){
$inicio = 0;
$fin = 25;
}else{
$inicio = 0;
$fin = 1000;
}


$msg = "";
$pais = array();
$table = "";
$pais[] = "Brazil";
if (isset($_POST['button']))// validamos si se hizo click
{
/*if ($_POST['mensaje'] != "" )
{ */

if ($_POST['compraventa'] == "2")
{
// tomamos el contenido de email_stock.php
$contenido = file_get_contents("email_stock.php");
// reemplazamos la palabra [*MENSAJE*] por lo que contenga $_POST['mensaje'].
$contenido = str_replace("[*MENSAJE*]",$_POST['mensaje'],$contenido);
// consulta que si esta bien
$result = $_SESSION['db']->getadminOfertasPublish($ob,$inicio,$fin);
/* function getadminOfertasPublish($ob,$i,$f)
{
$this->execute();
if ($ob == "Embarque")
{
$sql = "select * from oferta o,mes_embarq m where m.estado='1' and m.estado=o.estado and o.IdOferta=m.IdOferta and o.Embarque=m.Embarque and o.Embarque1=m.Embarque1 and o.Publicar = 1 order by m.id";
}elseif($ob == "Pais"){
$sql = "select * from oferta o,mes_embarq m where m.estado='1' and m.estado=o.estado and o.IdOferta=m.IdOferta and o.Embarque=m.Embarque and o.Embarque1=m.Embarque1 and o.Publicar = 1 order by o.paiscafe";
}else{
$sql = "SELECT * FROM oferta where m.estado='1' and Publicar = 1 ORDER BY $ob ";
}
return mysql_query($sql,$this->cn);
}

*/
$style = "class='lista'";
$table = ""; // variable $table q almacenará todo el contenido

$bgr = " style='background-color: #DEBE9E;border-top-width: 2px;border-top-style: solid;border-top-color: #703E18; text-align: right; color: #C7A861;' ";
$bgc = " style='text-align: center;' ";
$bgl = " style='text-align: left;' ";

$coun="Bolivia";

$style = " style='background-color: #DBCCC8;border-top-width: 2px;border-top-style: solid;border-top-color: #703E18; border-bottom-width: 2px;border-bottom-style: solid;border-bottom-color: #703E18; text-align: left; color: #552211; font-family: Arial, Helvetica, sans-serif; font-size: 12px;' ";

while( $row = mysql_fetch_array($result) )
{

if($coun==$row['paiscafe']) {




} else{

$style3 = " style='background-color: #F0EAE8;'";

$table .= "<tr $style3 height=15>";
$table .= "<td>&nbsp;</td>";
$table .= "<td>&nbsp;</td>";
$table .= "<td>&nbsp;</td>";
$table .= "<td>&nbsp;</td>";
$table .= "<td>&nbsp;</td>";
$table .= "<td>&nbsp;</td>";
$table .= "<td>&nbsp;</td>";
$table .= "<td>&nbsp;</td>";
$table .= "</tr>";

}



$table .= "<tr $style height=22>";



$table .= "<td>".$row['paiscafe']."</td>";

if ($row['Grade'] == "Other")
{
$table .= "<td>".$row['certi']."</td>";
}else{
$table .= "<td>".$row['Grade']."</td>";
}

if ($row['Sacos1'] != "")
{
$table .= "<td $bgl>".$row['Sacos1']." bags</td>";
}else{
$table .= "<td $bgl>".$row['Sacos']." bags</td>";
}




if ($row['Precio'] == "1") {

if ($row['Lb1'] != "" ) {

$table .= "<td $bgl>US$ ".$row['Lb1']."</td>";

}else {

if ($row['Lb'] != "") {

$table .= "<td $bgl>US$ ".$row['Lb']."</td>";

}else {

$table .= "<td $bgl>Negotiable</td>";

}

}

}else {

if ($row['Ny1'] != "" ) {

if ($row['PrecioMinimo1'] != "" && $row['PrecioMinimo1'] != "opcional" && $row['PrecioMinimo1'] != "-" && $row['PrecioMinimo1'] != "--") {

$table .= "<td $bgl>NY+".$row['Ny1'].", min US$ ".$row['PrecioMinimo1']."</td>";

}else {

$table .= "<td $bgl>NY+".$row['Ny1']."</td>";

}

}else if($row['Ny'] != "" ){

if ($row['PrecioMinimo'] != "" && $row['PrecioMinimo'] != "opcional" && $row['PrecioMinimo'] != "-" && $row['PrecioMinimo'] != "--") {

$table .= "<td $bgl>NY+".$row['Ny'].", min US$ ".$row['PrecioMinimo']."</td>";

}else {

$table .= "<td $bgl>NY+".$row['Ny']."</td>";

}

} else {

$table .="<td $bgl>Negotiable</td>";

}
}

if ($row['Embarque'] != "" and $row['Embarque1'] != "")
{
$table .= "<td $bgl>".$row['Embarque']." - ".$row['Embarque1']."</td>";
}else{
$table .= "<td $bgl>".$row['Embarque']."</td>";
}



if ($row['Calidad'] == "Otros" )
{
$table .= "<td $bgl>".$row['cali']."</td>";
}else{
$table .= "<td $bgl>".$row['Calidad']."</td>";
}


if ($row['Altura']=="" && $row['Altura1']=="") {

$table .= "<td $bgc>&nbsp;</td>";

}else{

$table .= "<td $bgc>".$row['Altura']." - ".$row['Altura1']." </td>";

}

$table .= "<td>".$row['Observaciones']."</td>";


$table .= "</tr>";

$coun=$row['paiscafe'];





} // reemplazamos [*BODY*] por el contenido de $table
$contenido = str_replace("[*BODY*]",$table,$contenido);



}


// inicio del envio del mail.
$to = $_POST['para'];
$subject = $_POST['asunto'];
$message = $contenido;
// To send HTML mail, the Content-type header must be set
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

/* Additional headers
$headers .= 'To: ' .$_POST['para']. "\r\n";
$headers .= 'From: <[email protected]>' . "\r\n";*/

mail($to, $subject, $message, $headers);

// echo $message; esto era para ver si habia valores.

echo "<script type = 'text/javascript'>";
echo ' document.location.href = "contact-form-tk.html"; ';
echo "</script>";
//}
}


$result = $_SESSION['db']->getOferta($_GET['Id']);
$row = mysql_fetch_array($result);
$idusuario = $row['IdUsuario'];
$correo =$_SESSION['db']->getCorreo($idusuario);
?>
<!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>Untitled Document</title>
<link href="cssFiles/styles.css" rel="stylesheet" type="text/css" />
<script type = "text/javascript" src = "Js/jquery.js" ></script>
<script type = "text/javascript" src = "Js/appQuery.js" ></script>
<script type = "text/javascript" src = "Js/facebox/facebox.js" ></script>
</head>

<body>
<div id="contactform">
<form id="form1" name="form1" method="post" action="">
<input type = "hidden" name = "compraventa" value = "2"/>
<p>Para
<input type = "text" name = "para" id = "para" value = "[email protected]"/>

<!--<select name="compraventa" id = "compraventa" onchange = "SetThis()" id="compraventa">
<option value = "0">seleccione</option>
<option value = "1">vendedor</option>
<option value = "2">comprador</option>
</select>-->
</p>
<!-- <p id = "FIELD">&nbsp;</p>
<p>Para
<input name="para" type="text" id="para" />
</p>-->
<p>
Asunto
<input type="text" name="asunto" id="asunto" />
</p>

<p>
Ordernar por :
<br />
Pais :
<input name="ordenar" type="radio" style = "width:10px" value = "fecha" checked/>
Fecha :
<input name="ordenar" type="radio" style = "width:10px" value = "pais"/>
</p>

<p>Comentarios
<textarea name="mensaje" id="mensaje" cols="45" rows="5"></textarea>
</p>
<p>
<input type="submit" name="button" id="button" value="Submit" />
</p>
</form>
</div>
</body>
</html>