Foros del Web » Programando para Internet » PHP »

Formulario Php

Estas en el tema de Formulario Php en el foro de PHP en Foros del Web. Hola amigos, como va? Les comento que tengo un problema con un formulario de contacto de una web. El codigo html es el siguiente: Cita: ...
  #1 (permalink)  
Antiguo 27/03/2010, 09:07
 
Fecha de Ingreso: marzo-2010
Mensajes: 28
Antigüedad: 14 años, 1 mes
Puntos: 0
Formulario Php

Hola amigos, como va? Les comento que tengo un problema con un formulario de contacto de una web.

El codigo html es el siguiente:
Cita:
<form name="contact" id="contact" action="contact.php" enctype="multipart/form-data">
<div style="width:177px;">
<div class="inp_h">
<input class="inp_2" type="text" name="name" value="Nombre y Apellido:" onfocus="this.value=''" />
</div>
<div class="inp_h">
<input class="inp_2" type="text" name="mail" value="E-mail:" onfocus="this.value=''" />
</div>
<div class="inp_h">
<input class="inp_2" type="text" name="Phone" value="Telefono:" onfocus="this.value=''" />
</div>
<textarea class="inp_3" rows="30" cols="40" onfocus="this.value=''">Mensaje:</textarea>
<div style="width:177px; text-align:right; margin:10px 2px 0 0;">
<a href="#" onClick="document.getElementById('contact').reset( )"></a><img src="images/spacer.gif" alt="" width="8" height="1" /><a href="#" onClick="document.getElementById('contact').submit ()"><img src="images/botton_2-02.gif" style="border:0px none;" alt="ENVIAR" /></a><br />

y el codigo php es el siguiente:

Cita:
<?php
Error_Reporting(E_ALL & ~E_NOTICE);

while ($request = current($_REQUEST)) {
if (key($_REQUEST)!='recipient') {
$pre_array=split ("&777&", $request);

$post_vars[key($_REQUEST)][0]=preg_replace ("/<[^>]*>/", "", $pre_array[0]);
$post_vars[key($_REQUEST)][1]=preg_replace ("/<[^>]*>/", "", $pre_array[1]);
}
next($_REQUEST);
}



reset($post_vars);


$subject="From ".$post_vars['Maximo Exponente'][0] ;
$headers= "From: ".$post_vars['[email protected]'][0] ."\n";
$headers.='Content-type: text/html; charset=iso-8859-1';
$message='';
while ($mess = current($post_vars)) {
if ((key($post_vars)!="i") && (key($post_vars)!="[email protected]") && (key($post_vars)!="Maximo Exponente")) {

$message.="<strong>".$mess[1]."</strong>&nbsp;&nbsp;&nbsp;".$mess[0]."<br>";
}
next($post_vars);
}

mail($_REQUEST['recipient'], $subject, "
<html>
<head>
<title>Contact letter</title>
</head>
<body>
<br>
".$message."
</body>
</html>" , $headers);
echo ("Your message was successfully sent!");

?>
<script>
resizeTo(300, 300);
</script>

Cuando entro a la web y relleno los campos, me dice que el msj ah sido enviado correctamente, pero no me llega nada :(
  #2 (permalink)  
Antiguo 27/03/2010, 09:30
Avatar de darkasecas  
Fecha de Ingreso: marzo-2005
Ubicación: SantaCata, NL, Mexico
Mensajes: 1.553
Antigüedad: 19 años, 1 mes
Puntos: 77
Respuesta: Formulario Php

Y donde envias el valor de "recipient"?
  #3 (permalink)  
Antiguo 27/03/2010, 10:38
 
Fecha de Ingreso: abril-2007
Ubicación: Tandil, Bs As, Argentina
Mensajes: 106
Antigüedad: 17 años
Puntos: 2
Respuesta: Formulario Php

Hola Pabliich.. si queres mira un poco este codigo que te dejo que es el que uso yo en mi sitio.. yo me manejo cno tablas pero por ahi vos lo podes adaptar a las capas que usas..

Código PHP:
<?php 
// Aca le pido que el nombre y el manesaje no esten vacios
            
if (($_POST["email"]<>'') && ($_POST["nombre"]<>'') && ($_POST["mensaje"]<>'')) { 
                
$ToEmail '/* TU EMAIL */'
                
$EmailSubject '/* Titulo del mail */'
                
$mailheader "From: ".$_POST["email"]."\r\n"
                
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n"
                
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"
                
$MESSAGE_BODY .= "Nombre: ".$_POST["nombre"]."<br>"
                
$MESSAGE_BODY .= "Telefono: ".$_POST["tel"]."<br>";
                
$MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>";
                
$MESSAGE_BODY .= "Ciudad: ".$_POST["ciudad"]."<br>";
                
$MESSAGE_BODY .= "Provincia: ".$_POST["provincia"]."<br>";
                
$MESSAGE_BODY .= "Pais: ".$_POST["pais"]."<br>";
                
$MESSAGE_BODY .= "Comentario: ".nl2br($_POST["mensaje"])."<br>"
                
mail($ToEmail$EmailSubject$MESSAGE_BODY$mailheader) or die ("Failure"); 
            
?>
            Gracias por comunicarse con nosotros. Su consulta sera atendida a la brevedad.

            <?php 
        
} else { 
        
?>
                    <form action="contacto.php" method="post">
                        <table width="415" border="0" cellpadding="0" cellspacing="0">
                          <tr>
                            <!-- Nombre y Apellido -->
                            <td width="55" height="29" class="firmas" align="right">* Nombre y Apellido</td>
                            <td width="3" height="29">&nbsp;</td>
                            <td width="140"><input name="nombre" style="background-color:#cccccc" type="text" class="firmas" id="nombre" size="30" /></td>
                            <td width="4" height="29" class="firmas">&nbsp;</td>
                            <!-- Telefono -->
                            <td width="82" height="29" class="firmas" align="right">Tel&eacute;fono</td>
                            <td width="4" height="29"></td>
                            <td width="127"><input name="tel" style="background-color:#cccccc" type="text" class="firmas" id="tel" size="30" /></td>
                          </tr>
                          <tr>
                            <!-- E-mail -->
                            <td height="22" valign="middle" class="firmas" align="right">* E-mail</td>
                            <td height="22">&nbsp;</td>
                            <td><input name="email" style="background-color:#cccccc" type="text" class="firmas" id="email" size="30" /></td>
                            <td height="30">&nbsp;</td>
                            <!-- Ciudad -->
                            <td height="22" valign="middle" class="firmas" align="right">Ciudad</td>
                            <td>&nbsp;</td>
                            <td><input name="ciudad" style="background-color:#cccccc" type="text" class="firmas" id="ciudad" size="30" /></td>
                          </tr>
                          <tr>
                            <!-- E-mail -->
                            <td height="22" valign="middle" class="firmas" align="right">Provincia</td>
                            <td height="22">&nbsp;</td>
                            <td><input name="provincia" style="background-color:#cccccc" type="text" class="firmas" id="provincia" size="30" /></td>
                            <td height="30">&nbsp;</td>
                            <!-- Ciudad -->
                            <td height="22" valign="middle" class="firmas" align="right">Pa&iacute;s</td>
                            <td>&nbsp;</td>
                            <td><input name="pais" style="background-color:#cccccc" type="text" class="firmas" id="pais" size="30" /></td>
                          </tr>
                          <tr>
                            <!-- Comentarios -->
                            <td class="firmas" valign="top" align="right">*Comentario</td>
                            <td height="26">&nbsp;</td>
                            <td colspan="5"><label>
                              <textarea name="mensaje" cols="78" rows="6" style="background-color:#cccccc" class="firmas" id="mensaje"></textarea>
                            </label></td>
                          </tr>
                          <tr>
                            <td height="26" colspan="2">&nbsp;</td>
                            <td colspan="5" class="firmas" align="right"><label>Los campos con * son obligatorios.  
                              <input name="submit" type="submit" class="firmas" value="Enviar" />
                              </label>
                                <label>
                                <input name="Submit222" type="reset" class="firmas" value="Restablecer" />
                              </label></td>
                          </tr>
                      </table>
                    </form>
                    <?php 
            
}; 
            
?>
Espero que te sirva!!! Saludos :D
  #4 (permalink)  
Antiguo 27/03/2010, 13:37
 
Fecha de Ingreso: marzo-2010
Mensajes: 28
Antigüedad: 14 años, 1 mes
Puntos: 0
Respuesta: Formulario Php

Cita:
Iniciado por darkasecas Ver Mensaje
Y donde envias el valor de "recipient"?

Disculpa mi ingonancia, a que te referis con eso? Saludos
  #5 (permalink)  
Antiguo 27/03/2010, 23:56
 
Fecha de Ingreso: agosto-2008
Ubicación: D,F
Mensajes: 412
Antigüedad: 15 años, 8 meses
Puntos: 4
Respuesta: Formulario Php

se refiere que en la variable recipient donde la ocupas o donde lo almacenas o algo asi
__________________
Si el amor a una mujer es igual al amor a la programacion
cual de las dos escojerias...mmmm buena pregunta jejeje
  #6 (permalink)  
Antiguo 28/03/2010, 02:39
Avatar de dargor  
Fecha de Ingreso: octubre-2009
Mensajes: 134
Antigüedad: 14 años, 6 meses
Puntos: 2
Respuesta: Formulario Php

aqui tambien hay otro codigo solo de la funcion mail()

[URL="http://www.forosdelweb.com/f18/error-enviar-formulario-correo-783774/#post3304962"]Enlace[/URL]
podrias usar tambien phpmailer, lo he utilizado y funciona muy bien.

Etiquetas: formulario
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 21:14.