Foros del Web » Programando para Internet » PHP »

envío de formulario

Estas en el tema de envío de formulario en el foro de PHP en Foros del Web. buenas!!!a ver si me pueden ayudar. he credo un formulario para que me llegen los datos a mi correo,pero me da error y no se ...
  #1 (permalink)  
Antiguo 12/02/2010, 06:05
 
Fecha de Ingreso: noviembre-2009
Mensajes: 209
Antigüedad: 14 años, 5 meses
Puntos: 0
envío de formulario

buenas!!!a ver si me pueden ayudar.
he credo un formulario para que me llegen los datos a mi correo,pero me da error y no se pq.
les dejo el código por si me pueden decir dnde está el error.
gracias!!!!

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Documento sin t&iacute;tulo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>

<body bgcolor="#0061AF">
<?
if (!$HTTP_POST_VARS){
?>

<div id="Layer2" style="position:absolute; left:340px; top:336px; width:104px; height:43px; z-index:2">
<form name="form11" action="envia_form_php.php" method=post>
<input type="submit" name="Submit" value="Enviar">
</form>
</div>
<div id="Layer1" style="position:absolute; left:28px; top:14px; width:261px; height:346px; z-index:1">
<table width="98%" height="103" border="0" cellpadding="3">
<tr>
<td height="66" colspan="6">
<div align="center"><strong>FORMULARIO DE INSCRIPCI&Oacute;N</strong></div></td>
</tr>
<tr>
<td width="7%" height="31" valign="top">Nombre:</td>
<td width="23%"><form name="form1" method="post" action="" >
<input type="text" name="nombre" size="25">
</form></td>
<td width="8%" valign="top">Apellidos:</td>
<td width="37%"><form name="form2" method="post" action="">
<input type="text" name="apellidos" size="35">
</form></td>
<td width="4%" valign="top">DNI:</td>
<td width="21%"><form name="form3" method="post" action="">
<input type="text" name="dni" size="21" align="right" alt="center">
</form></td>
</tr>
</table>
<table width="259%" border="0" cellpadding="3">
<tr>
<td width="9%" height="29" valign="top">Direcci&oacute;n:</td>
<td width="29%"><form name="form4" method="post" action="" >
<input type="text" name="direccion"size="35" >
</form></td>
<td width="7%" valign="top">Tel&eacute;fono:</td>
<td width="22%"><form name="form5" method="post" action="">
<input type="text" name="textfield5" size="20">
</form></td>
<td width="6%" valign="top">Email:</td>
<td width="27%"><form name="form6" method="post" action="" >
<input type="text" name="textfield6" >
</form></td>
</tr>
</table>
<table width="261%" border="0" cellpadding="3">
<tr>
<td width="23%" valign="top">Organismo/Universidad:</td>
<td width="35%"><form name="form7" method="post" action="">
<input type="text" name="organismo" size="38">
</form></td>
<td width="25%" valign="top">Tipo de participaci&oacute;n:</td>
<td width="17%"><form name="form8" method="post" action="">
<select name="participacion" size="1" >
<option>Comunicaci&oacute;n </option>
<option>P&oacute;ster </option>
<option>Oyente </option>
</select>
</form></td>
</tr>
</table>
<table width="170%" border="0" cellpadding="3">
<tr>
<td width="7%" valign="top">T&iacute;tulo:</td>
<td width="17%"><form name="form9" method="post" action="">
<input type="text" name="titulo" size="50">
</form></td>
<td width="30%" valign="top">Autores:</td>
<td width="46%"><form name="form12" method="post" action="">
<input type="text" name="autor" size="40">
</form></td>
</tr>
</table>
<table width="254%" border="0" cellpadding="3">
<tr>
<td width="23%" valign="top">Sesi&oacute;n Tem&aacute;tica:</td>
<td width="50%"><form name="form10" method="post" action="">
<input type="text" name="sesion" size="50">
</form></td>
<td width="7%" valign="top">Cuota:</td>
<td width="20%"><form name="form13" method="post" action="">
<input type="text" name="cuota" size="20">
</form></td>
</tr>
<?
}else{
//Estoy recibiendo el formulario, compongo el cuerpo
$cuerpo = "Formulario enviado\n";
$cuerpo .= "Nombre: " . $HTTP_POST_VARS["nombre"] . "\n";
$cuerpo .= "Apellidos: " . $HTTP_POST_VARS["apellidos"] . "\n";
$cuerpo .= "DNI: " . $HTTP_POST_VARS["dni"] . "\n";
$cuerpo .= "Dirección: " . $HTTP_POST_VARS["direccion"] . "\n";
$cuerpo .= "Teléfono: " . $HTTP_POST_VARS["telefono"] . "\n";
$cuerpo .= "Email: " . $HTTP_POST_VARS["email"] . "\n";
$cuerpo .= "Organismo/Universidad: " . $HTTP_POST_VARS["organismo"] . "\n";
$cuerpo .= "Participación: " . $HTTP_POST_VARS["participacion"] . "\n";
$cuerpo .= "Título: " . $HTTP_POST_VARS["titulo"] . "\n";
$cuerpo .= "Autores: " . $HTTP_POST_VARS["autor"] . "\n";
$cuerpo .= "Sesión: " . $HTTP_POST_VARS["sesion"] . "\n";
$cuerpo .= "Cuota: " . $HTTP_POST_VARS["cuota"] . "\n";

//mando el correo...
mail("[email protected]","Formulario recibido",$cuerpo);

//doy las gracias por el envío
echo "Gracias por rellenar el formulario. Se ha enviado correctamente.";
}
?>

</table>
</div>
</body>
</html>
  #2 (permalink)  
Antiguo 12/02/2010, 06:44
Avatar de CHuLoSoY  
Fecha de Ingreso: febrero-2002
Ubicación: Ribeira (Galicia)
Mensajes: 1.900
Antigüedad: 22 años, 2 meses
Puntos: 29
Respuesta: envío de formulario

Tu problema es puro html. Deberías leerte algún manual. Tienes un form por cada campo. Entonces no llegarás a enviar nada.
Haz un form para todos los campos y verás como sí funciona.
__________________
ESQUIO Dominios y Hosting
Las mejores características con los mejores precios.
  #3 (permalink)  
Antiguo 12/02/2010, 09:41
 
Fecha de Ingreso: noviembre-2009
Mensajes: 209
Antigüedad: 14 años, 5 meses
Puntos: 0
Respuesta: envío de formulario

gracias CHULOSOY,he cambiado el codigo y me sigue sin funcionar. te paso el codigo


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Documento sin t&iacute;tulo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>

<body bgcolor="#0061AF">
<?
if (!$HTTP_POST_VARS){
?>

<div id="Layer1" style="position:absolute; left:28px; top:14px; width:261px; height:346px; z-index:1">
<form action="envia_form_php.php" method=post> '
<table width="98%" height="103" border="0" cellpadding="3">
<tr>
<td height="66" colspan="6">
<div align="center"><strong>FORMULARIO DE INSCRIPCI&Oacute;N</strong></div></td>
</tr>
<tr>
<td width="7%" height="31" valign="top">Nombre:</td>
<td width="23%">
<input type="text" name="nombre" size="25">
</td>
<td width="8%" valign="top">Apellidos:</td>
<td width="37%">
<input type="text" name="apellidos" size="35">
</td>
<td width="4%" valign="top">DNI:</td>
<td width="21%">
<input type="text" name="dni" size="21" align="right" alt="center">
</td>
</tr>
</table>
<table width="259%" border="0" cellpadding="3">
<tr>
<td width="9%" height="29" valign="top">Direcci&oacute;n:</td>
<td width="29%">
<input type="text" name="direccion"size="35" >
</td>
<td width="7%" valign="top">Tel&eacute;fono:</td>
<td width="22%">
<input type="text" name="textfield5" size="20">
</td>
<td width="6%" valign="top">Email:</td>
<td width="27%">
<input type="text" name="textfield6" >
</td>
</tr>
</table>
<table width="261%" border="0" cellpadding="3">
<tr>
<td width="23%" valign="top">Organismo/Universidad:</td>
<td width="35%">
<input type="text" name="organismo" size="38">
</td>
<td width="25%" valign="top">Tipo de participaci&oacute;n:</td>
<td width="17%">
<select name="participacion" size="1" >
<option>Comunicaci&oacute;n </option>
<option>P&oacute;ster </option>
<option>Oyente </option>
</select>
</td>
</tr>
</table>
<table width="170%" border="0" cellpadding="3">
<tr>
<td width="7%" valign="top">T&iacute;tulo:</td>
<td width="17%">
<input type="text" name="titulo" size="50">
</td>
<td width="30%" valign="top">Autores:</td>
<td width="46%">
<input type="text" name="autor" size="40">
</td>
</tr>
</table>
<table width="254%" border="0" cellpadding="3">
<tr>
<td width="23%" valign="top">Sesi&oacute;n Tem&aacute;tica:</td>
<td width="50%">
<input type="text" name="sesion" size="50">
</td>
<td width="7%" valign="top">Cuota:</td>
<td width="20%">
<input type="text" name="cuota" size="20">
</td>
</tr>
<?
}else{
//Estoy recibiendo el formulario, compongo el cuerpo
$cuerpo = "Formulario enviado\n";
$cuerpo .= "Nombre: " . $HTTP_POST_VARS["nombre"] . "\n";
$cuerpo .= "Apellidos: " . $HTTP_POST_VARS["apellidos"] . "\n";
$cuerpo .= "DNI: " . $HTTP_POST_VARS["dni"] . "\n";
$cuerpo .= "Dirección: " . $HTTP_POST_VARS["direccion"] . "\n";
$cuerpo .= "Teléfono: " . $HTTP_POST_VARS["telefono"] . "\n";
$cuerpo .= "Email: " . $HTTP_POST_VARS["email"] . "\n";
$cuerpo .= "Organismo/Universidad: " . $HTTP_POST_VARS["organismo"] . "\n";
$cuerpo .= "Participación: " . $HTTP_POST_VARS["participacion"] . "\n";
$cuerpo .= "Título: " . $HTTP_POST_VARS["titulo"] . "\n";
$cuerpo .= "Autores: " . $HTTP_POST_VARS["autor"] . "\n";
$cuerpo .= "Sesión: " . $HTTP_POST_VARS["sesion"] . "\n";
$cuerpo .= "Cuota: " . $HTTP_POST_VARS["cuota"] . "\n";

//mando el correo...
mail("[email protected]","Formulario recibido",$cuerpo);

//doy las gracias por el envío
echo "Gracias por rellenar el formulario. Se ha enviado correctamente.";
}
?>

</table>
<div id="Layer2" style="position:absolute; left:340px; top:336px; width:104px; height:43px; z-index:2">
<input type="submit" name="Submit" value="Enviar">
</div>

</form>
</div>
</body>
</html>

MYCHAS GRACIAS
  #4 (permalink)  
Antiguo 12/02/2010, 09:43
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: envío de formulario

1) deberias usar <?php en lugar de <?
2) deberias usar $_POST en lugar de $HTTP_POST_VARS
3) por que "no funciona"? marca error? no envia el correo?
  #5 (permalink)  
Antiguo 12/02/2010, 09:55
 
Fecha de Ingreso: noviembre-2009
Mensajes: 209
Antigüedad: 14 años, 5 meses
Puntos: 0
Respuesta: envío de formulario

buenas, ya he cambiado las cosas q me has dicho.
cuando le doy al boton de enviar, me sale la tipica página de Internet Explorer:
"Internet Explorer no puede mostrar la pagina"
no se pq!!!!
gracias
  #6 (permalink)  
Antiguo 12/02/2010, 10:15
Avatar de CHuLoSoY  
Fecha de Ingreso: febrero-2002
Ubicación: Ribeira (Galicia)
Mensajes: 1.900
Antigüedad: 22 años, 2 meses
Puntos: 29
Respuesta: envío de formulario

Esa página se llama envia_form_php.php ???
Porque me da que estás enviando a una página que no existe, en cambio tu tienes formulario y php todo junto en la misma.
__________________
ESQUIO Dominios y Hosting
Las mejores características con los mejores precios.
  #7 (permalink)  
Antiguo 15/02/2010, 01:35
 
Fecha de Ingreso: noviembre-2009
Mensajes: 209
Antigüedad: 14 años, 5 meses
Puntos: 0
Respuesta: envío de formulario

hola de nuevo, la pagina claro que se llama envia_form_php.php. pero cuando le doy a enviar me sigue sin funcionar, me dice que no se puede mostrar la pagina.
voy a poner de nuevo el codigo por si podeis ver alun error, muchas gracias

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Documento sin t&iacute;tulo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>

<body bgcolor="#0061AF">
<?php
if (! $_POST ){
?>

<div id="Layer1" style="position:absolute; left:28px; top:14px; width:261px; height:346px; z-index:1">
<form action="envia_form_php.php" method=post> '
<table width="98%" height="103" border="0" cellpadding="3">
<tr>
<td height="66" colspan="6">
<div align="center"><strong>FORMULARIO DE INSCRIPCI&Oacute;N</strong></div></td>
</tr>
<tr>
<td width="7%" height="31" valign="top">Nombre:</td>
<td width="23%">
<input type="text" name="nombre" size="25">
</td>
<td width="8%" valign="top">Apellidos:</td>
<td width="37%">
<input type="text" name="apellidos" size="35">
</td>
<td width="4%" valign="top">DNI:</td>
<td width="21%">
<input type="text" name="dni" size="21" align="right" alt="center">
</td>
</tr>
</table>
<table width="259%" border="0" cellpadding="3">
<tr>
<td width="9%" height="29" valign="top">Direcci&oacute;n:</td>
<td width="29%">
<input type="text" name="direccion"size="35" >
</td>
<td width="7%" valign="top">Tel&eacute;fono:</td>
<td width="22%">
<input type="text" name="textfield5" size="20">
</td>
<td width="6%" valign="top">Email:</td>
<td width="27%">
<input type="text" name="textfield6" >
</td>
</tr>
</table>
<table width="261%" border="0" cellpadding="3">
<tr>
<td width="23%" valign="top">Organismo/Universidad:</td>
<td width="35%">
<input type="text" name="organismo" size="38">
</td>
<td width="25%" valign="top">Tipo de participaci&oacute;n:</td>
<td width="17%">
<select name="participacion" size="1" >
<option>Comunicaci&oacute;n </option>
<option>P&oacute;ster </option>
<option>Oyente </option>
</select>
</td>
</tr>
</table>
<table width="170%" border="0" cellpadding="3">
<tr>
<td width="7%" valign="top">T&iacute;tulo:</td>
<td width="17%">
<input type="text" name="titulo" size="50">
</td>
<td width="30%" valign="top">Autores:</td>
<td width="46%">
<input type="text" name="autor" size="40">
</td>
</tr>
</table>
<table width="254%" border="0" cellpadding="3">
<tr>
<td width="23%" valign="top">Sesi&oacute;n Tem&aacute;tica:</td>
<td width="50%">
<input type="text" name="sesion" size="50">
</td>
<td width="7%" valign="top">Cuota:</td>
<td width="20%">
<input type="text" name="cuota" size="20">
</td>
</tr>
<?php
}else{
//Estoy recibiendo el formulario, compongo el cuerpo
$cuerpo = "Formulario enviado\n";
$cuerpo .= "Nombre: " . $_POST ["nombre"] . "\n";
$cuerpo .= "Apellidos: " . $_POST ["apellidos"] . "\n";
$cuerpo .= "DNI: " . $_POST ["dni"] . "\n";
$cuerpo .= "Dirección: " . $_POST ["direccion"] . "\n";
$cuerpo .= "Teléfono: " . $_POST ["telefono"] . "\n";
$cuerpo .= "Email: " . $_POST ["email"] . "\n";
$cuerpo .= "Organismo/Universidad: " . $_POST ["organismo"] . "\n";
$cuerpo .= "Participación: " . $_POST ["participacion"] . "\n";
$cuerpo .= "Título: " . $_POST ["titulo"] . "\n";
$cuerpo .= "Autores: " . $HTTP_POST_VARS["autor"] . "\n";
$cuerpo .= "Sesión: " . $_POST ["sesion"] . "\n";
$cuerpo .= "Cuota: " . $_POST ["cuota"] . "\n";

mail("[email protected]","Formulario recibido",$cuerpo);

echo "Gracias por rellenar el formulario. Se ha enviado correctamente.";
}
?>

</table>
<div id="Layer2" style="position:absolute; left:340px; top:336px; width:104px; height:43px; z-index:2">
<input type="submit" name="Submit" value="Enviar">
</div>

</form>
</div>
</body>
</html>

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:49.