Título: Problema con este formulario
Publicado por: renzomr en 13 Noviembre 2006, 02:07 am
Hola, tengo una pagina y quiero hacerle un formulario de contacto lamentablemente nose nada de php y baje este formulario pre hecho....bueno el formulario tiene que ser de html a php y el que tengo esta malo porque me dice que no esta completo...despues borre la parte de los if para ver si lo enviaba y me enviaba un mail en blanco...a ver si alguien me lo puede corregir porfavor....
contacto.htm:
<html>
<head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="GENERATOR" content="Microsoft FrontPage 5.0"> <title>Contacto / Chocolateria Gnomos</title> </head>
<body>
<form action="correo.php" method="post" enctype="TEXT/PLAIN" name="Correo"> <table border="0" cellpadding="5" width="90%" bgcolor="#FFFFCC" style="border-collapse: collapse" bordercolor="#111111" cellspacing="0"> <tr> <td align="center" valign="top" width="30%"> <font color="#800000" size="2" face="Century Gothic"><strong>Tu nombre</strong></font></td> <td align="center"><input type="text" size="40" name="nombre"></td> </tr> <tr> <td align="center" valign="top" width="30%"> <font color="#800000" face="Century Gothic" size="2"><strong>Tu e-mail</strong></font></td> <td align="center"><input type="text" size="40" name="email"></td> </tr> <tr> <td align="center" valign="top" width="30%"> <font color="#800000" face="Century Gothic" size="2"><strong>Tu Mensaje</strong></font></td> <td align="center"><textarea name="mensaje" rows="5" cols="30" id="mensaje"></textarea> </td> </tr> <tr> <td align="center" valign="top"><input type="submit" name="Submit" value="Enviar"></td> <td align="center"> </td> </tr> </table> </form>
<p> </p> </body> </html>
correo.php:
<?php if (empty($nombre) || empty($email) || empty($mensaje)) { echo "<h2 align=\"center\">El formulario no está completo</h2>"; } else { mail ("info@chocolatesgnomos.com", "Chocolates Gnomos", "$mensaje", "From: $nombre <$email>" ); echo "<h2 align=\"center\">El mensaje ha sido enviado. Gracias.</h2>"; } ?>
Título: Re: Problema con este formulario
Publicado por: Luisango en 13 Noviembre 2006, 14:42 pm
Utiliza esto: correo.php: <?php if (phpversion() >= "4.2.0") { if ( ini_get('register_globals') != 1 ) { $supers = array('_REQUEST', '_ENV', '_SERVER', '_POST', '_GET', '_COOKIE', '_SESSION', '_FILES', '_GLOBALS' ); foreach( $supers as $__s) { if ( (isset($$__s) == true) && (is_array( $$__s ) == true) ) extract( $$__s, EXTR_OVERWRITE ); } unset($supers); } } else { if ( ini_get('register_globals') != 1 ) { $supers = array('HTTP_POST_VARS', 'HTTP_GET_VARS', 'HTTP_COOKIE_VARS', 'GLOBALS', 'HTTP_SESSION_VARS', 'HTTP_SERVER_VARS', 'HTTP_ENV_VARS' ); foreach( $supers as $__s) { if ( (isset($$__s) == true) && (is_array( $$__s ) == true) ) extract( $$__s, EXTR_OVERWRITE ); } unset($supers); } }
if($_POST[nombre]=="") { echo "<meta HTTP-EQUIV='refresh' content='1;url=contacto.htm'>"; exit(); } if($_POST[email]=="") { echo "<meta HTTP-EQUIV='refresh' content='1;url=contacto.htm'>"; exit(); } if($_POST[mensaje]=="") { echo "<meta HTTP-EQUIV='refresh' content='1;url=contacto.htm'>"; exit(); } $respuesta="index.htm"; // URL A LA QUE TE ENVIARA DESPUES DE ENVIARLO
/* AQUÍ ESPECIFICAS EL CORREO AL CUAL QUEIRES QUE SE ENVÍEN LOS DATOS DEL FORMULARIO, SI QUIERES ENVIAR LOS DATOS A MÁS DE UN CORREO, LOS PUEDES SEPARAR POR COMAS */ $para ="mail@mail.com"; //////////// AQUI TU EMAIL! $sujeto = "Contacto"; //////////// EL SUJETO!
$encabezado = "From: $nombre <$email>"; $encabezado .= "\nReply-To: $email"; $encabezado .= "\nX-Mailer: PHP/" . phpversion();
$ip=$REMOTE_ADDR; // AQUI EDITAS EL MENSAJE QUE TE LLEGARA $mensaje .= "---------------------------------------------\n"; $mensaje .= "CONTACTO DESDE: $ip\n"; $mensaje .= "---------------------------------------------\n"; $mensaje .= "Nombre: $_POST[nombre]\n"; $mensaje .= "Email: $_POST[email]\n"; $mensaje .= "\n"; $mensaje .= "Mensaje:\n"; $mensaje .= "$_POST[mensaje]\n"; $mensaje .= "---------------------------------------------\n";
if(!mail($para, $sujeto, $mensaje, $encabezado)) { echo "<meta HTTP-EQUIV='refresh' content='1;url=index.htm'>"; exit(); } else { echo "<meta HTTP-EQUIV='refresh' content='1;url=$respuesta'>"; }
?>
contacto.htm: <html>
<head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="GENERATOR" content="Microsoft FrontPage 5.0"> <title>Contacto / Chocolateria Gnomos</title> </head>
<body>
<form action="correo.php" method="post" name="Correo"> <table border="0" cellpadding="5" width="90%" bgcolor="#FFFFCC" style="border-collapse: collapse" bordercolor="#111111" cellspacing="0"> <tr> <td align="center" valign="top" width="30%"> <font color="#800000" size="2" face="Century Gothic"><strong>Tu nombre</strong></font></td> <td align="center"><input type="text" size="40" name="nombre"></td> </tr> <tr> <td align="center" valign="top" width="30%"> <font color="#800000" face="Century Gothic" size="2"><strong>Tu e-mail</strong></font></td> <td align="center"><input type="text" size="40" name="email"></td> </tr> <tr> <td align="center" valign="top" width="30%"> <font color="#800000" face="Century Gothic" size="2"><strong>Tu Mensaje</strong></font></td> <td align="center"><textarea name="mensaje" rows="5" cols="30" id="mensaje"></textarea> </td> </tr> <tr> <td align="center" valign="top"><input type="submit" name="Submit" value="Enviar"></td> <td align="center"> </td> </tr> </table> </form>
<p> </p> </body> </html>
Solo edita la configuracion del correo.php y estara listo :D
Título: Re: Problema con este formulario
Publicado por: renzomr en 13 Noviembre 2006, 15:17 pm
gracias te pasaste ;)
Título: Re: Problema con este formulario
Publicado por: Luisango en 13 Noviembre 2006, 17:39 pm
de nada ;)
|