Ver Mensaje Individual
  #5 (permalink)  
Antiguo 16/04/2011, 10:11
mglimas
 
Fecha de Ingreso: mayo-2006
Mensajes: 198
Antigüedad: 18 años
Puntos: 1
Respuesta: problema con formulario

Muchas gracias por tu respuesta uikekarallo. Intenté hacer lo que me indicas pero no me está saliendo. Cambie la última línea del php (envia.php) como me indicaste y luego le agregué los códigos al formulario contacto.html y lo guardé como php, con lo cual quedó contacto.php. Te copio los códigos a ver si me podes indicar dónde lo hice mal. Disculpá lo largo del código, resalte los agregados que me indicaste.

Muchísimas gracias por tu ayuda.

envia.php:

<?php
$usersmtp ="[email protected]"; // Entre las comillas va una cuenta de correo de su panel de control
$pass="LIMASn4tos"; // Entre las comillas va el password de la cuenta de correo
$destino="[email protected]"; // Entre las comillas la direccion de correo donde va a recibir los mails

// Se verifica que los datos han sido enviados desde el formulario, para la validaci� con el SMTP
if ( $_POST['enviar'] == "1")
{
if ( $_POST['nombre'] != "" && $_POST['email'] != "" && $_POST['consulta'] != "" )

{
// Se incluye la librer� necesaria para el envio
require_once("fzo.mail.php");

$mail = new SMTP("localhost",$usersmtp,$pass);

// Se configuran los parametros necesarios para el env�
$de = $usersmtp;
$a = $destino;
$asunto = "E-mail Contacto web marcolimas";
$cc = $_POST['[email protected]'];
$bcc = $_POST['bcc'];


$cuerpo = "Este es un e-mail enviado desde el formulario de contacto de www.marcolimas.com.ar" . "\n";
$cuerpo .= "Nombre: " .$_POST['nombre'] . "\n";
$cuerpo .= "Telefono: " .$_POST['telefono'] . "\n";
$cuerpo .= "Email: " .$_POST['email'] . "\n";
$cuerpo .= "Consulta: " .$_POST['consulta'] . "\n";



$header = $mail->make_header(
$de,
$a,
$asunto,
$_POST['prioridad'],
$cc,
$bcc
);

/*
Pueden definirse m� encabezados. Tener en cuenta la terminaci� de la
linea con (\r\n)

$header .= "Reply-To: ".$_POST['from']." \r\n";
$header .= "Content-Type: text/plain; charset=\"iso-8859-1\" \r\n";
$header .= "Content-Transfer-Encoding: 8bit \r\n";
$header .= "MIME-Version: 1.0 \r\n";
*/

// Se envia el correo y se verifica el error
Código PHP:
Ver original
  1. if( !$mail->smtp_send($de, $a, $header, $cuerpo, $cc, $bcc) )
  2. {
  3.   header('Location: /contacto.php?enviado=si');
  4.   exit();
  5. }
  6. else
  7. {
  8.   header('Location: /contacto.php?enviado=no');
  9.   exit();
  10. }
?>



Contacto.php:

Código PHP:
Ver original
  1. <?php
  2.   switch( @$_GET['enviado'] )
  3.   {
  4.     case 'si': $mensaje = '<p>Mensaje enviado</p>'; break;
  5.     case 'no': $mensaje = '<p>Mensaje no enviado</p>'; break;
  6.   }
  7. ?>
<!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>Marco Limas</title>
<style type="text/css">
<!--
Código HTML:
Ver original
  1. ACA VAN TODOS LOS DETALLES DE LAS ETIQUETAS QUE LOS SAQUE DE AQUI PARA QUE NO SEA TAN LARGO EL CODIGO
</style>
<script type="text/javascript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>

<body onload="MM_preloadImages('../Home/bio O.png','../Home/Música O.png','../Home/Texto O.png','../Home/proyectos O.png','../Home/Visuales O.png','../Home/Agenda O.png','../Home/Contactos O.png','../Home/prensa O.png','../Texto/una maleta O.jpg','../Texto/otros poemas O.png','facebook O.png','myspace O.png','you tube O.png','../Música/home O.png')">
<table width="950" height="565" border="0" align="center" background="../Home/Fondo Home.jpg">
<tr>
<td><div style="position:relative; width:950; height:555px; margin: 0 auto;">
<div id="apDiv4"><a href="../Música/Música.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('música','','../Home/Música O.png',1)"><img src="../Home/Música.png" name="música" width="68" height="15" border="0" id="música" /></a></div>
<div id="apDiv2"><a href="../Bio/Bio.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Bio','','../Home/bio O.png',1)"><img src="../Home/bio.png" name="Bio" width="30" height="15" border="0" id="Bio" /></a></div>
<div id="apDiv3"><img src="../Texto/leyendo.png" alt="Marco Limas leyendo" width="171" height="378" />
<div id="apDiv16"><a href="../Home/Home.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('home','','../Música/home O.png',1)"><img src="../Música/home.png" name="home" width="35" height="30" border="0" id="home" /></a></div>
</div>
<div id="apDiv"><a href="../Texto/Texto.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('texto','','../Home/Texto O.png',1)"><img src="../Home/Texto.png" name="texto" width="67" height="18" border="0" id="texto" /></a></div>
<div id="apDiv8"><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('visuales','','../Home/Visuales O.png',1)"><img src="../Home/Visuales.png" name="visuales" width="96" height="19" border="0" id="visuales" /></a></div>
<div id="apDiv6">
<!-- Formulario para completar con los datos -->

<form action="envia.php" method="POST">

<!--INICIO - Datos del formulario a completar -->
<table border="0" whidth="100%">
<tr>
<td align="rigth" width="19%"> *Nombre: </td>
<td align="rigth" width="81%"> <input type="text" name="nombre" width="50" size=40></input><br/><br></td>
</tr>
<tr>
<td align="rigth" width="19%">Telefono: </td>
<td align="rigth" width="81%"><input type="text" name="telefono" width="50" size=40></input><br/><br></td>
</tr>
<tr>
<td align="rigth" width="19%">*Email: </td>
<td align="rigth" width="81%"><input type="text" name="email" width="50" size=40></input><br/><br></td>
</tr>
<tr>
<td align="rigth" width="19%">*Consulta:</td>
<td align="rigth" width="81%"> <textarea rows="9" name="consulta" cols="40"></textarea>
<br/>
<br />
* Campos Obligadorios<br></td>
</tr>


<!--FIN - Datos del formulario a completar -->
<tr>
<td width="19%"></td>
<td align="rigth" width="81%"><br />
<input type="submit" value="Enviar e-mail" />
<input type="hidden" name="prioridad" value="3"/>
<input type="hidden" name="enviar" value="1"/></td>
</tr>
<tr>
<td width="19%"></td>
<td align="rigth" width="81%"><br />
Código PHP:
Ver original
  1. <?php echo $mensaje; ?>
</td>
</tr>
</table>
</form>
<!-- Fin Formulario para completar con los datos -->
</div>
<div id="apDiv9"><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('proyectos','','../Home/proyectos O.png',1)"><img src="../Home/proyectos.png" name="proyectos" width="109" height="23" border="0" id="proyectos" /></a></div>
<div id="apDiv10"><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('agenda','','../Home/Agenda O.png',1)"><img src="../Home/Agenda.png" name="agenda" width="81" height="19" border="0" id="agenda" /></a></div>
<div id="apDiv11"><a href="Contacto.html"><img src="../Home/cto O.png" alt="contacto O" width="26" height="15" /></a></div>
<div class="style13" id="apDiv5"><a href="mailto:[email protected]">prensa@limasw eb.com.ar</a></div>
<div id="apDiv12"><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('prensa','','../Home/prensa O.png',1)"><img src="../Home/prensa.png" name="prensa" width="75" height="19" border="0" id="prensa" /></a></div>
<div class="style13" id="apDiv7"><a href="mailto:[email protected]">info@marcolim as.com.ar</a></div>
<div id="apDiv13"><a href="http://www.facebook.com/search.php?q=Limas+Encuartos&amp;type=users" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('face','','facebook O.png',1)"><img src="facebook.png" name="face" width="37" height="37" border="0" id="face" /></a></div>
<div id="apDiv14"><a href="http://www.myspace.com/marcolimas" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('myspace','','myspace O.png',1)"><img src="myspace.png" name="myspace" width="37" height="37" border="0" id="myspace" /></a></div>
<div id="apDiv15"><a href="http://www.youtube.com/user/limasencuartos?feature=mhum" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('youtube','','you tube O.png',1)"><img src="you tube.png" name="youtube" width="96" height="39" border="0" id="youtube" /></a></div>
</div> </td>
</tr>
</table>
</body>
</html>