elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Usando Git para manipular el directorio de trabajo, el índice y commits (segunda parte)


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web
| | |-+  PHP (Moderador: #!drvy)
| | | |-+  Problema con este formulario
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Problema con este formulario  (Leído 1,784 veces)
renzomr

Desconectado Desconectado

Mensajes: 2


Ver Perfil
Problema con este formulario
« 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">&nbsp;</td>
        </tr>
    </table>
</form>

<p>&nbsp;</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>";
}
?>


En línea

Luisango


Desconectado Desconectado

Mensajes: 313



Ver Perfil WWW
Re: Problema con este formulario
« Respuesta #1 en: 13 Noviembre 2006, 14:42 pm »

Utiliza esto:
correo.php:
Código:
<?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:
Código:
<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">&nbsp;</td>
        </tr>
    </table>
</form>

<p>&nbsp;</p>
</body>
</html>


Solo edita la configuracion del correo.php y estara listo :D


En línea

Even better...
renzomr

Desconectado Desconectado

Mensajes: 2


Ver Perfil
Re: Problema con este formulario
« Respuesta #2 en: 13 Noviembre 2006, 15:17 pm »

gracias te pasaste ;)
En línea

Luisango


Desconectado Desconectado

Mensajes: 313



Ver Perfil WWW
Re: Problema con este formulario
« Respuesta #3 en: 13 Noviembre 2006, 17:39 pm »

de nada ;)
En línea

Even better...
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
(solucionado) Problema con este vbs...
Scripting
SuperDraco 2 3,398 Último mensaje 13 Mayo 2011, 02:33 am
por SuperDraco
problema con mi formulario
PHP
estebanjd 9 3,175 Último mensaje 7 Noviembre 2011, 02:55 am
por Carluís
Consulta sobre este formulario
Programación Visual Basic
POLLITOXD 0 1,248 Último mensaje 18 Mayo 2013, 20:51 pm
por POLLITOXD
como hicieron este formulario web???
Desarrollo Web
--bl455-- 6 2,612 Último mensaje 17 Julio 2014, 23:47 pm
por EFEX
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines