Foros del Web » Programando para Internet » PHP »

Problemas al pasar los datos de un formulario por PHP

Estas en el tema de Problemas al pasar los datos de un formulario por PHP en el foro de PHP en Foros del Web. Buenas y malas jejeje... tengo un pequeño problema ya que al llenar dos campos y poner enviar estos dos campor no se envian (espero estar ...
  #1 (permalink)  
Antiguo 03/12/2011, 10:13
 
Fecha de Ingreso: enero-2010
Mensajes: 50
Antigüedad: 14 años, 3 meses
Puntos: 0
Información Problemas al pasar los datos de un formulario por PHP

Buenas y malas jejeje... tengo un pequeño problema ya que al llenar dos campos y poner enviar estos dos campor no se envian (espero estar expresandome bien).


Los campos son los siguientes:

Parte <input>:

Código:
<table border="0" align="center">
<tr>
<td align="center" width="150" height="50">
    <label>
      <b>Fecha en Punta</b>
	</label>
</td>
<td align="center" width="350" height="50">
    <label>
      <input type="text" name="fecha0" value="Día" class="fecha0" onclick="this.value=''"/>&nbsp;&nbsp;<b>/</b>
      <input type="text" name="fecha1" value="Mes" class="fecha1" onclick="this.value=''"/>&nbsp;&nbsp;<b>/</b>
      <input type="text" name="fecha2" value="Año" class="fecha2" onclick="this.value=''"/>
    </label>
</td>
</tr>
</table>

Parte PHP:

Código:
  $mensaje.= "\nTeléfono: ". $_POST['codigoareaa'] . $_POST['telefono'];
  $mensaje.= "\nTeléfono (Uruguay): ". $_POST['codigoareab']. $_POST['telefonoUy'];

Código completo:

Código:
<html>
<head>
<title>Formulario</title>
</head>
<body>
<LINK REL=StyleSheet HREF="estilo.css" TYPE="text/css" MEDIA=screen>
<div align="center"><img src="/img/punta.jpg" width="754" height="122"></div>
<?php
if (!isset($_POST['email'])) {
?>
<br>
<br>
<br>
  <form action="<?=$_SERVER['PHP_SELF']?>" method="post" id="formulario" name="miFormulario" onSubmit="alert('A continuación verifique que sus datos estén correctos.'); return true;">
<table border="0" align="center">
<tr>
<td align="center" width="150" height="50">
    <label>
      <b>Nombre y Apellido</b>&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td align="center" width="350" height="50">
      <input name="nombre" type="text" value="Escribe tú nombre" class="nombre" onclick="this.value='';"/>&nbsp;&nbsp;-&nbsp;&nbsp;
    </label>
    <label>
       <input name="apellido" type="text" value="Escribe tú apellido" class="apellido" onclick="this.value=''"/>
    </label>
<br>
</td>
</tr>
</table>
<table border="0"align="center">
<tr>
<td align="center" width="150" height="50">
    <label>
      <center><b>Teléfono</b>
	</label>
</td>
<td align="center" width="350" height="50">
    <label>
      <input name="codigoareaa" type="text" class="campotelefono" value="(0054)(011)">&nbsp;-&nbsp;
	<label>
    </label>
      <input name="telefono" type="text" value=""></center>
    </label>
<br>
</td>
</tr>
</table>
<table border="0" align="center">
<tr>
<td align="center" width="150" height="50">
    <label>
      <center><b>Teléfono (Uruguay)</b>
</td>
<td align="center" width="350" height="50">
      <input name="codigoareab" type="text" class="campotelefono" value="(00598 53)">&nbsp;-&nbsp;
      <input name="telefonoUy" type="text" value=""></center>
    </label>
<br>
</td>
</tr>
</table>
<table border="0" align="center">
<tr>
<td align="center" width="150" height="50">
    <label>
      <b>BBM</b>
    </label>
</td>
<td align="center" width="350" height="50">
    <label>
      <input name="menssenger" type="text" value="BlackBerryMenssenger" onclick="this.value=''"/>
    </label>
</td>
</tr>
</table>
<table border="0" align="center">
<tr>
<td align="center" width="150" height="50">
    <label>
      <b>Email</b>
	</label>
</td>
<td align="center" width="350" height="50">
	<label>
      <input name="email" type="text" value="@" class="mail">
    </label>
</td>
</tr>
</table>
<table border="0" align="center">
<tr>
<td align="center" width="150" height="50">
    <label>
      <b>Fecha en Punta</b>
	</label>
</td>
<td align="center" width="350" height="50">
    <label>
      <input type="text" name="fecha0" value="Día" class="fecha0" onclick="this.value=''"/>&nbsp;&nbsp;<b>/</b>
      <input type="text" name="fecha1" value="Mes" class="fecha1" onclick="this.value=''"/>&nbsp;&nbsp;<b>/</b>
      <input type="text" name="fecha2" value="Año" class="fecha2" onclick="this.value=''"/>
    </label>
</td>
</tr>
</table>
<table border="0" align="center">
<tr>
<td align="center" width="506" height="50">
<input class="button" type="reset" name="Borrar datos" value="Borrar" /> | <input class="button" type="submit" name="Enviar datos" value="Enviar">
</td>
</tr>
</table>
  </form>
<?php
}else{
  $mensaje="Mensaje del formulario de contacto enviado desde: www.retrocomputacion.com.ar";
  $mensaje.= "\nNombre y Apellido: ".$_POST['nombre'];
  $mensaje.= "\nApellido: ".$_POST['apellido'];
  $mensaje.= "\nTeléfono: ". $_POST['codigoareaa'] . $_POST['telefono'];
  $mensaje.= "\nTeléfono (Uruguay): ". $_POST['codigoareab']. $_POST['telefonoUy'];
  $mensaje.= "\nFecha en Punta: ".$_POST['fecha0']. $_POST['fecha1']. $_POST['fecha2'];
  $mensaje.= "\nEmail: ".$_POST['email'];
  $mensaje.= "\nBBM: ". $_POST['menssenger'];
  $destino= "[email protected]";
  $remitente = $_POST['email'];
  $asunto = "Mensaje enviado por: ".$_POST['nombre']. "\t" .$_POST['apellido'];
  mail($destino,$asunto,$mensaje,"FROM: $remitente");
  echo "<table border='1' align='center' style='margin-top:-150px;'>";
  echo ("<tr><td><center><b>Mensaje enviado por:&nbsp;</b> ".$_POST['nombre']. "\t" .$_POST['apellido']."</center></td></tr>");
  echo "</table>";
  echo "<table border='1' align='center' style='margin-top:-150px;'>";
  /*echo ("<tr><td><center><b>Mensaje enviado por:&nbsp;</b> ".$_POST['nombre']. "\t" .$_POST['apellido']."</center></tr></td><br/><br/>");*/
  echo ("<tr><td><b>Nombre: </b>".$_POST['nombre']."</tr></td><br/>");
  echo ("<tr><td><b>Apellido: </b>".$_POST['apellido']."</tr></td><br/>");
  echo ("<tr><td><b>Teléfono: </b>". $_POST['telefono']."</tr></td><br/>");
  echo ("<tr><td><b>Teléfono (Uruguay): </b>". $_POST['telefonoUy']."</tr></td><br/>");
  echo ("<tr><td><b>Fecha en Punta: </b>". $_POST['fecha0']. "<b>/</b>" .$_POST['fecha1']. "<b>/</b>" . $_POST['fecha2']. "</tr></td><br/>");
  echo ("<tr><td><b>Email: </b>".$_POST['email'])."</tr></td><br/>";
  echo ("<tr><td><b>BlackBerryMenssenger: </b>". $_POST['menssenger']."</tr></td><br/><br/>");
  echo"</table>";
  echo"</br>";
  echo "<table border='0' align='center'>";
  print'<tr><td><center><a href="envio.php" style="text-decoration: none";><input class="button" type="submit" name="Formulario" value="Formulario"></a> | <a href="index.html" style="text-decoration: none";><input class="button" type="submit" name="Inicio" value="Inicio"></a></center></tr></td>';
  echo"</table>";
?>
<?php
}
?>
<script language='javascript'>
alert('Muchas gracias por contactarnos. Le responderemos a la brevedad.');
</script>;
</body>
</html>
  #2 (permalink)  
Antiguo 03/12/2011, 11:45
Avatar de carlos_belisario
Colaborador
 
Fecha de Ingreso: abril-2010
Ubicación: Venezuela Maracay Aragua
Mensajes: 3.156
Antigüedad: 14 años
Puntos: 461
Respuesta: Problemas al pasar los datos de un formulario por PHP

si haces esto
Código PHP:
Ver original
  1. print_r($_POST)
luego de enviar el formulario que te da??

por cierto como sugerencia el short_tag de php no esta recomendado seria bueno que utlizaras el <?php y te evites problemas, saludos
__________________
aprende d tus errores e incrementa tu conocimientos
it's not a bug, it's an undocumented feature By @David
php the right way
  #3 (permalink)  
Antiguo 03/12/2011, 12:00
Avatar de emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 10 meses
Puntos: 1567
Respuesta: Problemas al pasar los datos de un formulario por PHP

Tu "código completo", ejecutado tal cual está , tiene muchos errores.
Por ejemplo tan solo al cargar la página se te ejecuta esto
Código HTML:
Ver original
  1. <script language='javascript'>
  2. alert('Muchas gracias por contactarnos. Le responderemos a la brevedad.');
  3. </script>;

en el onsubmit ejecutás un alert(), cuando si lo que estás intentando es validar, deberías crear una función que lo haga y segun los resultados mostrar o no un alert o mensaje
la función mail() se ejecuta, esa parte al menos está bien.
te recomiendo que elimines todo el javascript y pruebes el form, una vez que recibas todos los valores que te interesan, recién ahi, procedas con la validación

Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.

Etiquetas: formulario, html
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 08:32.