Hola, buen día.
Hice un formulario de contacto y lo puse dentro de etiquetas <div></div> porque en la página que estoy haciendo no use tablas.
El problema se plantea en que dentro del <div> el formulario no hace nada y probandolo en un html se envia perfectamente.
El formulario es este:
Código PHP:
<?php /*empieza formulario*/
if($Submit){
@$Nombre = $_POST['Nombre'];
@$Email = $_POST['Email'];
@$Adultos = $_POST['Adultos'];
@$Menores = $_POST['Menores'];
@$Consulta = $_POST['Consulta'];
$header = "From: $Nombre <$Email>\n";
$header .= "X-Mailer: PHP4\n"; //mailer
$header .= "MIME-Version: 1.0\n";
$header .= "Reply-to: ".$Email."\n";
$header .= "Content-type: text/html; charset=iso-8859-1\n";
//************************************************************************/
$cuerpo = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
<html><head>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
</head>
<body>
<tr>
<td bgcolor='#fea941' align='left' valign='top'>" . $Nombre . " envía una consulta desde MiSitio.com.ar
<br>Nombre: " . $Nombre . "
<br><a href='mailto: " . $Email . "'> " . $Email . "</a>
<br>Adultos: " . $Adultos . "
<br>niños: " . $Menores . "
<br>Consulta: " . $Consulta . "
</td></tr></body></html>";
mail('[email protected]','Visitante de MiSitio.com.ar',$cuerpo,$header);
echo "<table width='383' height='200' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td align='center' valign='middle'>Su consulta ha sido enviada, gracias<br>
</td>
</tr>
</table>";
}
else{ //se manda// ?>
Código HTML:
<form action="consultas.php" method="post" name="form1" target="_self">
<table width="383" height="250" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top">
<table width="360" height="20" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="middle" class="opcion">Nombre<br>
<input name="Nombre" type="text" id="Nombre" size="40" style="width:360px" class="formularios"></td>
</tr>
</table>
<table width="360" height="20" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="240" align="left" valign="middle" class="opcion">E-mail<br>
<input name="Email" type="text" id="Email" size="40" style="width:360px" class="formularios"></td>
</tr>
</table><table width="360" height="20" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="240" align="left" valign="middle" class="opcion">adultos<br>
<input name="Adultos" type="text" id="Adultos" size="40" style="width:360px" class="formularios"></td>
</tr>
</table><table width="360" height="20" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="240" align="left" valign="middle" class="opcion">niños<br>
<input name="Menores" type="text" id="Menores" size="40" style="width:360px" class="formularios"></td>
</tr>
</table>
<table width="360" height="60" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="middle" class="opcion">Consulta<br>
<textarea name="Consulta" cols="40" rows="5" id="textarea" style="width:360px" class="formularios"></textarea></td>
</tr>
</table>
<table width="360" height="20" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><input type="submit" name="Submit" value="Enviar" class="bt-form">
<input type="reset" name="Submit2" value="Borrar" class="bt-form"></td>
</tr>
</table></td>
</tr>
</table>
</form>
Código PHP:
<? }
//fin del formulario//?>
Asi funciona, ahora, cuando lo pongo dentro del los <div></div> deja de funcionar
Código HTML:
<div id="form" class="form"><?php /*empieza formulario*/
if($Submit){
@$Nombre = $_POST['Nombre'];
@$Email = $_POST['Email'];
@$Adultos = $_POST['Adultos'];
@$Menores = $_POST['Menores'];
@$Consulta = $_POST['Consulta'];
$header = "From: $Nombre <$Email>\n";
$header .= "X-Mailer: PHP4\n"; //mailer
$header .= "MIME-Version: 1.0\n";
$header .= "Reply-to: ".$Email."\n";
$header .= "Content-type: text/html; charset=iso-8859-1\n";
//************************************************************************/
$cuerpo = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
<html><head>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
</head>
<body>
<tr>
<td bgcolor='#fea941' align='left' valign='top'>" . $Nombre . " envía una consulta desde MiSitio.com.ar
<br>Nombre: " . $Nombre . "
<br><a href='mailto: " . $Email . "'> " . $Email . "</a>
<br>Adultos: " . $Adultos . "
<br>niños: " . $Menores . "
<br>Consulta: " . $Consulta . "
</td></tr></body></html>";
mail('[email protected]','Visitante de MiSitio.com.ar',$cuerpo,$header);
echo "<table width='383' height='200' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td align='center' valign='middle'>Su consulta ha sido enviada, gracias<br>
</td>
</tr>
</table>";
}
else{ //se manda// ?>
<form name="form1" action="consultas.php" method="post" target="_self">
Nombre<br><input name="Nombre" id="Nombre" type="text" value="" size="80" style="width:250px" class="formobligatorio"/>
<br>E-mail<br><input name="Email" id="Email" type="text" value="" size="80" style="width:250px" class="formobligatorio"/>
<br>Cantidad de adultos<br><input name="Adultos" id="Adultos" type="text" value="" size="80" style="width:50px" class="formopcional"/>
<br>Cantidad de niños<br><input name="Menores" id="Menores" type="text" value="" size="80" style="width:50px" class="formopcional"/>
<br>Consulta<br>
<textarea name="Consulta" cols="40" rows="5" wrap="nowrap" class="formobligatorio" id="Consulta" style="width:250px" value="" type="text"></textarea>
<input type="submit" name"Submit" class="boton_form" value="Enviar"/>
<input name="reset" type="Reset" class="boton_form" value="Borrar" /></form><? }
//fin del formulario//?></div>
La pregunta es ¿hay que agregar algo al <form action="">? ¿me falta algún pedazo de código? o simplemente no se puede?
gracias por el tiempo
Germán