Ver Mensaje Individual
  #7 (permalink)  
Antiguo 24/09/2012, 14:36
jorgejorge
 
Fecha de Ingreso: diciembre-2006
Mensajes: 12
Antigüedad: 17 años, 10 meses
Puntos: 0
Respuesta: phpmailer: página de gracias

Pongo el codigo, aunque es un poco largo. No sé si hay otro modo de poner el codigo. Hay un problema con los charsets, pero no me preocupa, porque en la página original se ven bien:

<?php


//CONFIGURACION
$direccion_envio= '[email protected]'; //la direccion a la que se enviara el email.
$url= 'http://www.ago-construcciones.com/prueba.php'; //la URL donde esta publicado el formulario. SIN la barra al final

//HAY QUE LLAMAR A GRACIAS.PHP, PERO NO SÉ CÓMO
//$thank="gracias.php";
//header("Location: gracias.php");
//echo "<script language=Javascript> location.href=\"gracias.php\"; </script>";

//FIN CONFIGURACION
?>


<?PHP
//proceso del formulario
// si existe "enviar"...
if (isset ($_POST['enviar'])) {

// vamos a hacer uso de la clase phpmailer,
require("class.phpmailer.php");

$mail = new PHPMailer();

//autenticamos el SMTP
$mail->IsSMTP();
$mail->Mailer = "smtp";
$mail->SMTPAuth = true;
$mail->Mailer = "smtp";
$mail->Host = "mail.dxmedia.net"; //Localhost
$mail->Username = "[email protected]";
$mail->Password = "cobain";



//recogemos las variables y configuramos PHPMailer
$mail->From = $_POST['email'];
$mail->FromName = $_POST['nombre'];
$mail->AddAddress($direccion_envio);
$mail->Subject = "Formulario de Contacto de Ago-Construcciones - Castellano";
$mail->AddReplyTo($_POST['email'],$_POST['nombre']);
$mail->IsHTML(true);
$mail->CharSet="UTF-8";
$empresa=$_POST['empresa'];
$poblacion=$_POST['poblacion'];
$telefono=$_POST['telefono'];
$comentario=$_POST['comentario'];
$reforma_de_oficina=$_POST['reforma_de_oficina'];
$reforma_de_optica=$_POST['reforma_de_optica'];
$reforma_de_farmacia=$_POST['reforma_de_farmacia'];
$reforma_local_comercial=$_POST['reforma_local_comercial'];
$reforma_nave_industrial=$_POST['reforma_nave_industrial'];
$construccion_general=$_POST['construccion_general'];


//comprobamos si todos los campos fueron completados
if ($_POST['email']!='' && $_POST['nombre']!='' && $_POST['telefono']!='' && $_POST['comentario']!='') {


//armamos el html
$contenido = '<html><body>';
$contenido .= '<h2>Formulario de Contacto de Ago-Construcciones - Castellano</h2>';
$contenido .= '<p>Enviado el '. date("d M Y").'</p>';
$contenido .= '<hr />';
$contenido .= '<p>Nombre: <strong>'.$_POST['nombre'].'</strong>';
$contenido .= '<p>Email: <strong>'.$_POST['email'].'</strong>';
$contenido .= '<p>Empresa: <strong>'.$empresa.'</strong>';
$contenido .= '<p>Telefono: <strong>'.$telefono.'</strong>';
$contenido .= '<p>Poblacion: <strong>'.$poblacion.'</strong>';
$contenido .= '<p>Comentario: <strong>'.$comentario.'</strong>';
$contenido .= '<hr />';
$contenido .= '<p><strong>ESTOY INTERESADO EN LOS SIGUIENTES SECTORES:</strong></p>';
$contenido .= '<p>Reforma de oficina: <strong>'.$reforma_de_oficina.'</strong>';
$contenido .= '<p>Reforma de optica: <strong>'.$reforma_de_optica.'</strong>';
$contenido .= '<p>Reforma de farmacia: <strong>'.$reforma_de_farmacia.'</strong>';
$contenido .= '<p>Reforma de local comercial: <strong>'.$reforma_local_comercial.'</strong>';
$contenido .= '<p>Reforma de nave industrial: <strong>'.$reforma_nave_industrial.'</strong>';
$contenido .= '<p>Construccion general: <strong>'.$construccion_general.'</strong>';
$contenido .= '<hr />';
$contenido .= '</body></html>';


$mail->Body = $contenido;
//$mail->AddAttachment('archivos/'.$nuevonombre.'', $nuevonombre); // optional name
// si todos los campos fueron completados enviamos el mail

$mail->Send();

$flag='ok';
$mensaje='<div id="ok" style="position:relative; left:60px; color:#ff0000; font-face:arial,helvetica,sans-serif">Gracias por contactar con nosotros. En breve nos pondremos en contacto con usted.</div>';
} else {

//si no todos los campos fueron completados se frena el envio y avisamos al usuario
$flag='err';
$mensaje='<div id="error" style="position:relative; left:60px; color:#ff0000; font-face:arial,helvetica,sans-serif">Los campos marcados (*) se han de rellenar correctamente.<br>'.$error_archivo.'</div>';

}
}


?>






<!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" lang="es">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>A.G.O. Acondicionamiento de Oficinas. Contacto.</title>
<link href="ago.css" rel="stylesheet" type="text/css"/>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>


</head>
<body>
<div id="cos">
<div id="fondo">

<div id="menu" style="height:780px"><img src="img/logo_AGO.jpg" alt="Logo de A.G.O. Gestión y ejecucion integral de obras y proyectos." title="A.G.O. Construcción, Reforma e Interiorismo de oficinas, locales comerciales, ópticas y naves industriales." border="0" usemap="#Map" />
<map name="Map" id="Map">
<area shape="rect" coords="10,5,183,96" title="A.G.O. Construcción, Reforma e Interiorismo de oficinas, locales comerciales, ópticas y naves industriales." href="index.html" />
</map></li>

</div>

<div id="cabecera_empresa">
<div id="idiomas" ><span id="idiomas-nolink">Castellano</span> | <a href="contactanos_ca.php">Català</a> | <a href="contactanos_en.php">English</a></div>
<div id="titulo_cabecera">GESTIÓN INTEGRAL DE OBRAS</div>
</div>

<div id="contenido" style="height:90px";>
<table cellpadding="0" cellspacing="0" width="800px" align="right" border="0">
<tr>
<td colspan=4 class="txt_contenido2">
<p>&nbsp;</p>
<h1>Contacto. Ayúdanos a informarte.</h1> </td>
</tr>
</table>
</div>

<div id="cuadro_clientes3" style="padding-left:210px;">
<? echo $mensaje; /*mostramos el estado de envio del form */ ?>
<? if ($flag!='ok') { ?>
<form action="<?php echo $PHP_SELF;?>" method="post" name="formulario" class="form">

<table cellpadding="0" cellspacing="0" width="590px" align="left" border="0">

<tr>
<td class="checkbox"><input type="checkbox" name="reforma_de_oficina" value="Interesado" /> <strong>Reforma de oficina</strong></td>
<td class="checkbox2"><input type="checkbox" name="reforma_de_optica" value="Interesado" /> <strong>Reforma de óptica</strong></td>
<td class="checkbox2"><input type="checkbox" name="reforma_de_farmacia" value="Interesado" /> <strong>Reforma de farmacia</strong></td>
<td>&nbsp; </td>
</tr>

<tr>
<td class="checkbox"><input type="checkbox" name="reforma_local_comercial" value="Interesado" /> <strong>Reforma local comercial</strong><br><br></td>
<td class="checkbox2"><input type="checkbox" name="reforma_nave_industrial" value="Interesado" /> <strong>Reforma nave industrial</strong><br><br></td>
<td class="checkbox2"><input type="checkbox" name="construccion_general" value="Interesado" /> <strong>Construcción general</strong><br><br></td>
<td>&nbsp; </td>
</tr>
</table>


<table cellpadding="0" cellspacing="0" width="575px" height="" align="left" border="0">
<tr>
<td class="checkbox" width="">*Nombre:</td>
<td class="checkbox2"> <input <? if (isset ($flag) && $_POST['nombre']=='') { echo 'class="error"';} else {echo 'class="campo"';} ?> type="text" name="nombre" value="<? echo $_POST['nombre'];?>" /></td>

<td class="checkbox3" width="" align="right">Empresa: &nbsp; &nbsp;</td>
<td class="checkbox2"><input name="empresa" type="text"></td>
</tr>

<tr>
<td class="checkbox">*Teléfono:</td>
<td class="checkbox2"> <input <? if (isset ($flag) && $_POST['telefono']=='') { echo 'class="error"';} else {echo 'class="campo"';} ?> type="text" name="telefono" value="<? echo $_POST['telefono'];?>" /></td>

<td class="checkbox3" align="right"> Población: &nbsp; </td>
<td class="checkbox2"><input name="poblacion" type="text" ></td>
</tr>

<tr>
<td class="checkbox">*Email:</td>
<td class="checkbox2"> <input <? if (isset ($flag) && $_POST['email']=='') { echo 'class="error"';} else {echo 'class="campo"';} ?> type="text" name="email" value="<? echo $_POST['email'];?>" /></td>

<td class="checkbox2"></td>
<td class="checkbox2"></td>
</tr>

<tr>
<td class="checkbox" valign="top">*Comentario:</td>
<td class="checkbox2" colspan="3"><textarea <? if (isset ($flag) && $_POST['comentario']=='') { echo 'class="error"';} else {echo 'class="campo"';} ?> name="comentario" type="text" rows="3" wrap="physical" style="width:420px;">
</textarea></td>
</tr>

<tr>
<td class="checkbox" valign="top">*obligatorio</td>
<td class="checkbox2" colspan="3" valign="top" style="text-align:right;"><input class="boto" type="submit" name="enviar" value=" &nbsp; Enviar &nbsp; "> &nbsp; &nbsp; &nbsp;

</form>

<? } ?>

</td>
</tr>
</table>


<!-- end form-->


</div>


</div>
</div>

</body>
</html>

Última edición por jorgejorge; 24/09/2012 a las 14:41