Ver Mensaje Individual
  #3 (permalink)  
Antiguo 06/04/2011, 12:43
Avatar de juanote
juanote
 
Fecha de Ingreso: enero-2003
Ubicación: Valencia
Mensajes: 285
Antigüedad: 21 años, 3 meses
Puntos: 10
Respuesta: Envio formulario

Adjunto parte de codigo

<?php
include_once("../configuration.php");
include_once("../funciones.php");
include_once("../clases/boletines.php");

comprueba_identificado_admin();
$bo_id = trim($_REQUEST["bo_id"]);
$bol = new boletines($bo_id);
if ($_SESSION["tipo_usuario_juan"]==2){
//Si ya existe el bolet�n y el usuario no lo tiene asignado lo tiro.
switch ($bol->get_tipo()){
case 1:{
$sql = "select count(us_id) as conta from tbl_usuarios where us_id=".$_SESSION["usuario_admin"]." and us_env1=1";
break;
}
case 2:{
$sql = "select count(us_id) as conta from tbl_usuarios where us_id=".$_SESSION["usuario_admin"]." and us_env2=1";
break;
}
case 3:{
$sql = "select count(us_id) as conta from tbl_usuarios where us_id=".$_SESSION["usuario_admin"]." and us_env3=1";
break;
}
}

$res = mysql_query($sql, $GLOBALS["dbd"]);
$row = mysql_fetch_array($res, MYSQL_ASSOC);
if ($row["conta"]==0){
header("Location: ./boletines_lista.php");
}

}
$tipo_envio = $_REQUEST["tipo_envio"];
if ($tipo_envio==1){ //Env�o de prueba
$correo = $_REQUEST["correo"];
include_once("./genera_boletin.php");

$asunto="Newsletter";
$titulo=$asunto;
$responder="[email protected]";
$remite="[email protected]";
$remitente="Newsletter";
$cabecera ="MIME-Version: 1.0\n";
$cabecera .="From: ".$remitente."<".$remite.">\n";
$cabecera .="Return-path: ". $remite."\n";
$cabecera .="Reply-To: ".$responder."\n";
$cabecera .="X-Mailer: PHP/". phpversion()."\n";
$cabecera .="Content-Type: text/html; charset=\"ISO-8859-1\"\n";

if ($bien = mail($correo, $titulo, $salida,$cabecera)){
//if (1==1){
header("Location:./boletines_envio.php?bo_id=".$bo_id."&resul=1");
}else{
header("Location:./boletines_envio.php?bo_id=".$bo_id."&resul=1&error =1");
}
die();

}

if ($tipo_envio==2){
include_once("./genera_boletin.php");
$asunto = addslashes($_REQUEST["asunto"]);
$titulo=$asunto;
$responder="[email protected]";
$remite="[email protected]";
$remitente="Newsletter ";
$cabecera ="MIME-Version: 1.0\n";
$cabecera .="From: ".$remitente."<".$remite.">\n";
$cabecera .="Return-path: ". $remite."\n";
$cabecera .="Reply-To: ".$responder."\n";
$cabecera .="X-Mailer: PHP/". phpversion()."\n";
$cabecera .="Content-Type: text/html; charset=\"ISO-8859-1\"\n";

//Pillo todos los destinatarios del bolet�n
switch($boletin->get_tipo()){
case 1:{
$auxi = " de_bol1=1 ";
break;
}
case 2:{
$auxi = " de_bol2=1 ";
break;
}
case 3:{
$auxi = " de_bol3=1 ";
break;
}
}
$sql = "select * from tbl_destinatarios where ".$auxi." and de_activo=1";
$res = mysql_query($sql, $GLOBALS["dbd"]);
while ($row = mysql_fetch_array($res, MYSQL_ASSOC)){
mail($row["de_correo"], $titulo, $salida,$cabecera);

}
$boletin->set_estado("Enviado");
$boletin->set_fecha_envio(date('Y-m-d'));
$boletin->almacena_datos();
//Me creo una hist�rico de envios
$sql="insert into tbl_envios_boletin (en_id, en_ref_boletin, en_asunto, en_fecha) values(null,".$boletin->get_id().",'".$asunto."','".date('Y-m-d')."')";
$res = mysql_query($sql, $GLOBALS["dbd"]);
header("Location:./boletines_envio.php?bo_id=".$bo_id."&resul=2");
die();
}

?>