Ver Mensaje Individual
  #3 (permalink)  
Antiguo 20/06/2010, 21:04
Soulshifter
 
Fecha de Ingreso: junio-2010
Mensajes: 3
Antigüedad: 13 años, 10 meses
Puntos: 0
Respuesta: Problema con formulario y recuperación de datos php

Quedó así... sin embargo tampoco muestra los valores
Código PHP:
Ver original
  1. <?php
  2.  
  3. include("config.php");
  4.  
  5. error_reporting(E_ALL ^ E_NOTICE);
  6.  
  7.  
  8. $msg = Array();
  9. $error = Array();
  10.  
  11.  
  12. function RecogeDatos()
  13. {
  14.     global $config, $msg, $error;
  15.     $db = @mysql_connect($config['mysql_host'], $config['mysql_user'], $config['mysql_pass']);
  16.     if (!$db) return $error[] = 'Database: '.mysql_error();
  17.     if (!@mysql_select_db($config['mysql_dbname'], $db)) return $error[] = 'Database: '.mysql_error();
  18.     $query = "SELECT * FROM `obesidad` where `rut` = '".mysql_real_escape_string($_POST['rut'])."'";
  19.     $res = mysql_query($query, $db);
  20.     while ($row = mysql_fetch_array($res, MYSQL_ASSOC))
  21.     {
  22.         $nombre = $row["Nombre"];
  23.         $rut = $row["RUT"];
  24.         $telefono1 = $row["Teléfono 1"];
  25.         $telefono2 = $row["Teléfono 2"];
  26.         $telefono3 = $row["Teléfono 3"];
  27.         $email = $row["email"];
  28.         $edad = $row["Edad"];
  29.         $sexo = $row["Sexo"];
  30.     }
  31.     if (!$res) return $error[] = 'Database: '.mysql_error();
  32.     mysql_free_result($res);
  33.     mysql_close($db);
  34. }
  35. ?>
  36. <html>
  37. <head>
  38.     <title>Sistema de Seguimiento</title>
  39.     <meta http-equiv="Pragma" content="no-cache"/>
  40.     <meta http-equiv="Cache-Control" content="no-cache"/>
  41.     <style type="text/css" media="screen">@import url(style.css);</style>
  42.     <script language="JavaScript" src ="scripts.js"></script>
  43. </head>
  44. <body>
  45.  
  46.     <center>
  47.     <div class="logo1"></div>
  48. <div style="width:500px">
  49.         <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
  50.         <table width="500" border="0" cellspacing="1" cellpadding="3">
  51.             <tr class="head"><th colspan="2">Ingrese el RUT</th></tr>
  52.             <tr>
  53.               <th width="191">Rut: </th>
  54.               <td width="294" align="center"><input type="text" name="rut" size="30" maxlength="100" id="rut" value="<?php echo "$rut";?>"/></td>
  55.             </tr>
  56.             <tr class="head"><th colspan="2">Datos del Usuario</th></tr>
  57.             <tr>
  58.                 <th>Nombre: </th><td align="center"><input name="nombre" type="text" disabled size="30" maxlength="100" value="<?php echo RecogeDatos();?>"/></td>
  59.             </tr>
  60.             <tr>
  61.                 <th>Teléfono 1: </th><td align="center"><input name="telefono1" type="text" disabled size="30" maxlength="100" value="<?php echo "$telefono1";?>"/></td>
  62.             </tr>
  63.             <tr>
  64.                 <th>Teléfono 2: </th><td align="center"><input name="telefono2" type="text" disabled size="30" maxlength="100" value="<?php echo "$telefono2";?>"/></td>
  65.             </tr>
  66.             <tr>
  67.                 <th>Teléfono 3: </th>
  68.               <td align="center"><input name="telefono3" type="text" disabled size="30" maxlength="100" value="<?php echo "$telefono3";?>"/></td>
  69.             </tr>
  70.             <tr>
  71.                 <th>E-mail: </th><td align="center"><input name="email" type="text" disabled size="30" maxlength="100" value="<?php echo "$email";?>"/></td>
  72.             </tr>
  73.             <tr>
  74.                 <th>Edad: </th><td align="center"><input name="edad" type="text" disabled size="30" maxlength="100" value="<?php echo "$edad";?>"/></td>
  75.             </tr>          
  76.                
  77.                 <th>Sexo:</th><td align="center"><input name="sexo" type="text" disabled size="30" maxlength="100" value="<?php echo "$sexo";?>"/></td>
  78.         </table>
  79.         <input type="button" class="button2" value="Inicio" onClick="location.href='index.php';"/>
  80.         <input type="button" class="button2" value="Regresar" onClick="history.go(-1)" />
  81.         <input type="submit" name="botonbuscar" class="button2" value="Buscar"/>
  82.         </form>
  83.     </div>
  84.     </center>
  85.         </div>
  86.         <div style="width:300px"></div>
  87.         <p align="center">&nbsp;</p>
  88. </table>
  89. </body>
  90. </html>

Última edición por Soulshifter; 20/06/2010 a las 21:19