Foros del Web » Soporte técnico » Ayuda General »

Formulario con php

Estas en el tema de Formulario con php en el foro de Ayuda General en Foros del Web. HOLA ESTOY HACIENDO UNA WEB CON UN FORMULARIO CON VALIDACION Y UN ARCHIVO PHP PARA ENVIAR EL RESULTADO DEL FORMULARIO A UN EMAIL. TODO VA ...
  #1 (permalink)  
Antiguo 22/02/2013, 21:51
 
Fecha de Ingreso: noviembre-2010
Mensajes: 48
Antigüedad: 13 años, 4 meses
Puntos: 1
Formulario con php

HOLA ESTOY HACIENDO UNA WEB CON UN FORMULARIO CON VALIDACION Y UN ARCHIVO PHP PARA ENVIAR EL RESULTADO DEL FORMULARIO A UN EMAIL.
TODO VA BIEN EL FORMULARIO ANDA PERFECTO LA VALIDACION TAMBIEN Y SE ENVIAN LOS EMAILS. EL UNICO TEMA ES QUE EN LOS EMAILS NO LLEGA LA INFORMACION QUE INGRESA LA PERSONA QUE LLENA EL FORMULARIO (LLEGAN LOS EMAILS PERO FALTA LA INFORMACION QUE INGRESA EL VISITANTE).


LES ENVIO EL CODIGO DEL FORMULARIO QUE ESTA EN EL HTML:

<form action="php/quickcontact.php" method="post" id="contactwidget">
<div class="inp_l">
<div class="inp_r"><input type="text" name="wname" id="wname" value="Nombre" size="22" tabindex="11" alt="Nombre" /></div>
</div>

<div class="inp_l">
<div class="inp_r"><input type="text" name="wemail" id="wemail" value="Email" size="22" tabindex="12" alt="Email" /></div>
</div>
<table>
<tr>
<td class="text_t_l"></td>
<td class="text_t"></td>
<td class="text_t_r"></td>
</tr>
<tr>
<td class="text_l"></td>
<td class="text_m"><textarea name="wmessage" id="wmessage" cols="28" rows="6" tabindex="13" title="Mensaje">Mensaje</textarea></td>
<td class="text_r"></td>
</tr>
<tr>
<td class="text_b_l"></td>
<td class="text_b"></td>
<td class="text_b_r"></td>
</tr>
</table>
<div class="loading"></div>
<div><input type="hidden" name="wcontactemail" id="wcontactemail" value="[email protected]" /></div>
<div><input type="hidden" name="wcontacturl" id="wcontacturl" value="php/quickcontact.php" /></div>
<div><a href="php/quickcontact.php" id="wformsend" class="button" tabindex="14"><span>Enviar</span></a></div>
</form>


Y EL DEL ARCHIVO PHP DE ENVIO:

<?php
if ((isset($_POST['wname'])) && (strlen(trim($_POST['wname'])) > 0)) {
$contact_name = stripslashes(strip_tags($_POST['wname']));
} else {$contact_name = 'No contact name entered';}
if ((isset($_POST['wemail'])) && (strlen(trim($_POST['wemail'])) > 0)) {
$contact_email = stripslashes(strip_tags($_POST['wemail']));
} else {$contact_email = 'No email entered';}
if ((isset($_POST['wmessage'])) && (strlen(trim($_POST['wmessage'])) > 0)) {
$contact_message = stripslashes(strip_tags($_POST['wmessage']));
} else {$contact_message = 'No message entered';}
ob_start();
?>
<html>
<head>
<style type="text/css">
</style>
</head>
<body>
<table width="550" border="1" cellspacing="2" cellpadding="2">
<tr bgcolor="#eeffee">
<td>Name</td>
<td><?=$wname;?></td>
</tr>
<tr bgcolor="#eeeeff">
<td>Email</td>
<td><?=$wemail;?></td>
</tr>
<tr bgcolor="#eeeeff">
<td>Message</td>
<td><?=$wmessage;?></td>
</tr>
</table>
</body>
</html>
<?
$body = ob_get_contents();

$to = '[email protected]';
$email = '[email protected]';
$fromaddress = "[email protected]";
$fromname = "Online Contact";

require("phpmailer.php");

$mail = new PHPMailer();

$mail->From = "[email protected]";
$mail->FromName = "Contacto";
$mail->AddAddress("[email protected]","Pablo"); //change to your email address

$mail->WordWrap = 50;
$mail->IsHTML(true);

$mail->Subject = "Quickcontact: Mensaje recibido";
$mail->Body = $body;
$mail->AltBody = "This is the text-only body";

if(!$mail->Send()) {
$recipient = '[email protected]'; //change to your email address
$subject = 'contactwidget failed';
$content = $body;
mail($recipient, $subject, $content, "From: [email protected]\r\nReply-To: $email\r\nX-Mailer: DT_formmail");
exit;
}
?>

EL FORMULARIO SE ENVIA PERFECTO LLEGA EL EMAIL PERFECTO. TAMBIEN LLEGA EN EL CUERPO DEL MENSAJE LA TABLA ESPECIFICADA EN EL ARCHIVO PHP PERO EN ESTA TABLA NO SE VEN LOS DATOS QUE ESCRIBE EL VISITANTE. ES DECIR EN EL MENSAJE RECIBIDO SE VE:

Name:
Email:
Message:

PERO NO SE CARGAN LOS DATOS INGRESADOS AL LLENAR EL FORMULARIO. SUPONGO QUE DEBE HABER UN ERROR DE RELACION ENTRE LAS ETIQUETAS DEL FORMULARIO Y LAS DEL ARCHIVO PHP PARA QUE ESTE CARGUE LA INFORMACION.

NO SE MUCHO DE PHP LES AGRADECERIA MUCHO SU AYUDA. DESDE YA MUCHAS GRACIAS
  #2 (permalink)  
Antiguo 23/02/2013, 05:24
Avatar de emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 9 meses
Puntos: 1567
Respuesta: Formulario con php

Se puede saber porque hacés esto
Código:
<div><a href="php/quickcontact.php" id="wformsend" class="button" tabindex="14"><span>Enviar</span></a></div>
En lugar de utilizar un <input type="submit"> que es lo que corresponde

SAludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.
  #3 (permalink)  
Antiguo 23/02/2013, 06:04
 
Fecha de Ingreso: noviembre-2010
Mensajes: 48
Antigüedad: 13 años, 4 meses
Puntos: 1
Respuesta: Formulario con php

Probe con submit pero no me sirve sigue sin enviar los datos ingresados
  #4 (permalink)  
Antiguo 23/02/2013, 06:33
Avatar de emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 9 meses
Puntos: 1567
Respuesta: Formulario con php

Cita:
Iniciado por pabloem1972 Ver Mensaje
Probe con submit pero no me sirve sigue sin enviar los datos ingresados
Te sugiero que bajes la última versión de

http://code.google.com/a/apache-extr...downloads/list
y ejecutes los ejemplos básicos de la carpeta examples para ver como funciona
Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.
  #5 (permalink)  
Antiguo 23/02/2013, 10:04
 
Fecha de Ingreso: noviembre-2010
Mensajes: 48
Antigüedad: 13 años, 4 meses
Puntos: 1
Respuesta: Formulario con php

No me dio resultado el email llega perfecto pero no llega lo que se ingresa en el formulario. El tema me parece es la relacion en tre el formulario y el php.
  #6 (permalink)  
Antiguo 23/02/2013, 13:00
Avatar de emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 9 meses
Puntos: 1567
Respuesta: Formulario con php

probá esto en tu server a ver que ves
Código PHP:
Ver original
  1. <?php
  2. $wname = "A";
  3. $wemail = "B";
  4. $wmessage = "C";
  5. ?>
  6. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  7. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  8. <html xmlns="http://www.w3.org/1999/xhtml">
  9. <head>
  10. <title>titulo</title>
  11. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  12. </head>
  13. <body>
  14. <table width="550" border="1" cellspacing="2" cellpadding="2">
  15.  <tr bgcolor="#eeffee">
  16.  <td>Name</td>
  17.  <td><?php echo $wname; ?></td>
  18.  </tr>
  19.  <tr bgcolor="#eeeeff">
  20.  <td>Email</td>
  21.  <td><?=$wemail; ?></td>
  22.  </tr>
  23.  <tr bgcolor="#eeeeff">
  24.  <td>Message</td>
  25.  <td><?=$wmessage;?></td>
  26.  </tr>
  27.  </table>
  28. </body>
  29. </html>

Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.
  #7 (permalink)  
Antiguo 23/02/2013, 13:39
 
Fecha de Ingreso: noviembre-2010
Mensajes: 48
Antigüedad: 13 años, 4 meses
Puntos: 1
Respuesta: Formulario con php

PUSE EL CODIGO QUE ME DIGISTE COMO PAGINA WEB EN EL SERVIDOR Y EN EL NAVEGADOR SE VE LA TABLA

Name A
Email B
Message C
  #8 (permalink)  
Antiguo 23/02/2013, 13:50
Avatar de emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 9 meses
Puntos: 1567
Respuesta: Formulario con php

Bueno, a ver esto

vos tenes

Código:
<?php
 if ((isset($_POST['wname'])) && (strlen(trim($_POST['wname'])) > 0)) {
 $contact_name = stripslashes(strip_tags($_POST['wname']));
 } else {$contact_name = 'No contact name entered';}
 if ((isset($_POST['wemail'])) && (strlen(trim($_POST['wemail'])) > 0)) {
 $contact_email = stripslashes(strip_tags($_POST['wemail']));
 } else {$contact_email = 'No email entered';}
 if ((isset($_POST['wmessage'])) && (strlen(trim($_POST['wmessage'])) > 0)) {
 $contact_message = stripslashes(strip_tags($_POST['wmessage']));
 } else {$contact_message = 'No message entered';}
 ob_start();
 ?>
 <html>
 <head>
 <style type="text/css">
 </style>
 </head>
 <body>
 <table width="550" border="1" cellspacing="2" cellpadding="2">
 <tr bgcolor="#eeffee">
 <td>Name</td>
 <td><?=$wname;?></td>
 </tr>
 <tr bgcolor="#eeeeff">
 <td>Email</td>
 <td><?=$wemail;?></td>
 </tr>
 <tr bgcolor="#eeeeff">
 <td>Message</td>
 <td><?=$wmessage;?></td>
 </tr>
 </table>
 </body>
 </html>
Al inicio, si se reciben los posts y estos no están vacios estás defininiendo las variables que estan en negrita, pero luego, al generar la tabla e incluir los resultados, usas nombre de variables que no existen (las que están en rojo), tienen que ser iguales a las de arriba. Y acordate que tenés que hacerle submit al form

Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.
  #9 (permalink)  
Antiguo 23/02/2013, 15:20
 
Fecha de Ingreso: noviembre-2010
Mensajes: 48
Antigüedad: 13 años, 4 meses
Puntos: 1
Respuesta: Formulario con php

HICE LO QUE ME DIJISTE PERO AL PONER EL BOTON EN SUBMIT LOGRA ENVIAR EL FORMULARIO CON LOS DATOS AL EMAIL (LLEGAN LOS DATOS INGRESADOS) PERO EL FORMULARIO NO HACE LA VALIDACION Y AL HACER CLICK ME ENVIA EN EL NAVEGADOR A UNA VENTANA CON LA PAGINA PHP DE ENVIO DONDE SE VE LA TABLA Y LOS DATOS.
ESTARIA BUENO BUSCAR ALGUNA COMBINACION ENTRE:

1) ESTE CODIGO

<div><a href="php/enviar.php" id="wformsend" class="button" tabindex="14"><span>Enviar</span></a></div>

(EL CUAL ME PERMITE HACER LA VALIDACION Y VER EL MENSAJE DE ENVIADO PERFECTAMENTE )

Y

2) ESTE OTRO:

<input type="submit" value="Enviar" />

(QUE ME PERMITE ENVIAR EL FORMULARIO CON LOS DATOS PERFECTAMENTE)

SE PODRAN COMBINAR AMBOS?
  #10 (permalink)  
Antiguo 23/02/2013, 16:07
Avatar de emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 9 meses
Puntos: 1567
Respuesta: Formulario con php

Si, es natural que te pase eso porque el problema fundamenta les que toda tu estructura no está bien echa, estás poniendo cosas que individualmente funcionan, de hecho, el email ahora lo recibís. PEro has copiado y pegado código sin ningún criterio
Validar, en realidad tampoco validás nada.
El body mandalo asi
Código PHP:
Ver original
  1. <?php
  2. $body = "
  3. <html>
  4. <head>
  5. </head>
  6. <body>
  7. <table width='550' border='1' cellspacing='2' cellpadding='2'>
  8. <tr bgcolor='#eeffee'>
  9. <td>Name</td>
  10. <td>$wname</td>
  11. </tr>
  12. <tr bgcolor='#eeeeff'>
  13. <td>Email</td>
  14. <td>$wemail</td>
  15. </tr>
  16. <tr bgcolor='#eeeeff'>
  17. <td>Message</td>
  18. <td>$wmessage</td>
  19. </tr>
  20. </table>
  21. </body>
  22. </html>
  23. ?>
  24. ";
cambiando los nombres de las variables como ya te señalé y quitá eso de
$body = ob_get_contents();

Lo más convenientes es que busques algún tutorial de envío de forms con php para manejar algunos conceptos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.
  #11 (permalink)  
Antiguo 23/02/2013, 16:24
 
Fecha de Ingreso: noviembre-2010
Mensajes: 48
Antigüedad: 13 años, 4 meses
Puntos: 1
Respuesta: Formulario con php

COMPROBE QUE EL BOTON DEL FORMULARIO NO NECESITA EL CODIGO php/enviar.php PARA VALIDAR COLOCANDO # TAMBIEN FUNCIONA

<div><a href="php/enviar.php o #" id="wformsend" class="button" tabindex="14"><span>Enviar</span></a></div>

PERO DEJA DE FUNCIONAR SI QUITO EL LINK <a href=... NO SE PORQUE. SE VE QUE FORMA PARTE DEL WIDGET (JAVASCRIPT) DEL SITIO QUE AVISA SI FALTA ALGUN DATO Y DA UN MENSAJE CUANDO EL EMAIL SE HA ENVIADO. LO QUE HABRIA QUE HACER ES VER SI EN ALGUNA PARTE DEL FORMULARIO SE PERMITE PONER EL INPUT MAS QUE NADA COMBINARLO CON EL BOTON ENVIAR SUPONGO
  #12 (permalink)  
Antiguo 24/02/2013, 17:16
 
Fecha de Ingreso: noviembre-2010
Mensajes: 48
Antigüedad: 13 años, 4 meses
Puntos: 1
Respuesta: Formulario con php

Hola perdoname el desorden el tema es que el diseño y programacion html ya estan terminados. Tambien los script del sitio. Lo unico que falta es el archivo php que envie el email (en realidad envia el email pero sin los datos ingresados) y yo de php no se casi nada. Fui armando el php segun consejos por eso esta tan mezclado.

Probe el codigo anterior que me digiste en el php
pero el formulario sigue sin funcionar llega el email pero sin los datos como antes
  #13 (permalink)  
Antiguo 24/02/2013, 19:03
Avatar de webosiris
Moderador egiptólogo
 
Fecha de Ingreso: febrero-2002
Ubicación: Luxor, Egipto
Mensajes: 10.725
Antigüedad: 22 años, 2 meses
Puntos: 998
Respuesta: Formulario con php

Tema cerrado por repetir temas innecesariamente en 5 lugares distintos.
Así es imposible ayudarte.

Etiquetas: emails, php
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.
Tema Cerrado




La zona horaria es GMT -6. Ahora son las 18:31.