Ver Mensaje Individual
  #9 (permalink)  
Antiguo 11/04/2013, 09:04
Avatar de guardarmicorreo
guardarmicorreo
 
Fecha de Ingreso: noviembre-2012
Ubicación: Córdoba
Mensajes: 1.153
Antigüedad: 11 años, 5 meses
Puntos: 84
Respuesta: atributo action de form ¿no recarga/refresca la página?

Cita:
Iniciado por emprear Ver Mensaje
Sigo sin entender, a ver si ete ejemplo (muy básico) te aclara el panorama

Archivo index_conectar.php
Código PHP:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <title>titulo</title>
  6. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  7. </head>
  8. <body>
  9. <?php
  10. $error = "";
  11. $script = "";
  12. if(isset($_POST['procesar'])){
  13. if(($_POST['nombre'] != "") && ($_POST['apellido'] != "")){
  14. echo "gracias " . $_POST['nombre'] . " " . $_POST['apellido'];
  15. $script = "<script>document.getElementById('ingresa_datos').style.display = 'none';</script>";
  16. }else{
  17. $error = "<p>Debe completar ambos campos</p>";
  18. }
  19. }
  20. ?>
  21. <form name="ingresa_datos" method="post" action="index_conectar.php" id="ingresa_datos">
  22. nombre: <input type="text" name="nombre" value="<?php if(isset($_POST['nombre'])){echo $_POST['nombre'];} ?>" /><br />
  23. nombre: <input type="text" name="apellido" value="<?php if(isset($_POST['apellido'])){echo $_POST['apellido'];} ?>" /><br />
  24. <input type="submit" name="procesar" value="procesar"/>
  25. </form>
  26. <?php
  27. echo "$error\n";
  28. echo "$script\n";
  29. ?>
  30. </body>
  31. </html>

Saludos
lo he leído entero, no veo en qué me ayuda :S

cuando presionas el botón procesar y se crean las variables post te imprime en pantalla esas variables. en el form apuntas al mismo documento. no veo que se diferencie del mío