Ver Mensaje Individual
  #3 (permalink)  
Antiguo 23/11/2009, 14:52
Avatar de dcreate
dcreate
 
Fecha de Ingreso: octubre-2009
Ubicación: Veracruz
Mensajes: 536
Antigüedad: 14 años, 6 meses
Puntos: 22
Respuesta: Busco un ejemplo de update please

algo asi:

index.php

Código php:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>Documento sin t&iacute;tulo</title>
  6. <style type="text/css">
  7. <!--
  8. .Estilo1 {
  9.     font-family: Verdana, Arial, Helvetica, sans-serif;
  10.     font-weight: bold;
  11. }
  12. .Estilo2 {
  13.     font-size: 24pt;
  14.     font-weight: bold;
  15.     font-family: Arial, Helvetica, sans-serif;
  16. }
  17. -->
  18. </style>
  19. </head>
  20.  
  21. <body>
  22. <table width="890" border="0" align="center">
  23.   <tr>
  24.     <td>&nbsp;</td>
  25.     <td><div align="center"><span class="Estilo2">BUSCAR CUENTA A MODIFICAR</span></div></td>
  26.     <td>&nbsp;</td>
  27.   </tr>
  28. </table>
  29. <br /><br />
  30. <form id="form1" name="form1" method="post" action="mostrar.php">
  31.   <table width="360" border="1" align="center">
  32.     <tr>
  33.       <td width="167"><div align="right" class="Estilo1">clave </div></td>
  34.       <td width="177"><label>
  35.         <input name="alias" type="text" id="alias" />
  36.       </label></td>
  37.     </tr>
  38.     <tr>
  39.       <td align="right">
  40.         <input type="submit" name="Submit" value="BUSCAR" />
  41.       </td>
  42.       <td><label>
  43.         <input type="button" name="Submit2" value="CANCELAR" onclick="document.location='inicio.php'"/>
  44.       </label></td>
  45.     </tr>
  46.   </table>
  47. </form>
  48.  
  49.  
  50. </body>
  51. </html>

mostrar.php

Código php:
Ver original
  1. <?php
  2. include "conexion.php";
  3. $consecutivo=$_POST['alias'];
  4. conectar();
  5. $bus=mysql_query("select *from tabla where consecutivo='$consecutivo'");
  6. $cons=mysql_fetch_assoc($bus);
  7. ?>
  8.  
  9. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  10. <html xmlns="http://www.w3.org/1999/xhtml">
  11. <head>
  12. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  13. <title></title>
  14. <script>
  15. function validar(formulario)
  16. {
  17. if(formulario.nombre.value=='')
  18. {
  19. alert("LLENAR CAMPOS NECESARIOS\n-NOMBRE");
  20. formulario.nombre.focus();
  21. return false;
  22. }
  23.  
  24. if(formulario.password.value=='')
  25. {
  26. alert("LLENAR CAMPOS NECESARIOS\n-");
  27. formulario.password.focus();
  28. return false;
  29. }
  30. return true;
  31. }
  32. </script>
  33. <style type="text/css">
  34. <!--
  35. .Estilo1 {
  36.     font-size: 24pt;
  37.     font-weight: bold;
  38.     font-family: Arial, Helvetica, sans-serif;
  39. }
  40. .Estilo2 {font-family: Verdana, Arial, Helvetica, sans-serif}
  41. -->
  42. </style>
  43. </head>
  44.  
  45. <body onload="form1.nombre.focus()">
  46. <div align="center"><span class="Estilo1">MODIFICAR DATOS</span></div>
  47. <form onsubmit="return validar(this)" id="form1" name="form1" method="post" action="modificar.php">
  48.   <p>&nbsp;</p>
  49.   <table width="200" border="1" align="center">
  50.     <tr>
  51.       <td><span class="Estilo2"><strong>
  52.         <label>        </label>
  53.       </strong>        
  54.           <label></label>
  55.       </span>        <label><div align="right" class="Estilo2"><strong>NOMBRE:</strong></div>
  56.       </label></td>
  57.       <td><input name="nombre" type="text" id="nombre" style="text-transform:uppercase" value="<?php echo $cons['nombre'];?>" size="50" maxlength="50"/></td>
  58.     </tr>
  59.     <tr>
  60.       <td><div align="right" class="Estilo2"><strong>alias:
  61.       </strong></div>        
  62.         <span class="Estilo2"><strong>
  63.         <label></label>
  64.       </strong></span></td>
  65.       <td><div style="text-transform:uppercase"><?php echo $cons['alias'];?></div><input name="alias" type="hidden" id="alias" style="text-transform:uppercase" value="<?php echo $cons['consecutivo']; ?>" size="30" maxlength="30" /></td>
  66.     </tr>
  67.     <tr>
  68.       <td><div align="right" class="Estilo2"><strong>PASSWORD:
  69.       </strong></div>        
  70.         <span class="Estilo2"><strong>
  71.         <label></label>
  72.       </strong></span></td>
  73.       <td><input name="dato" type="text" id="password" value="<?php echo $cons['dato'];?>" size="30" maxlength="30" /></td>
  74.     </tr>
  75.   </table>
  76.   <p>&nbsp;</p>
  77.   <table width="200" border="0" align="center">
  78.     <tr>
  79.       <td align="right">
  80.         <input type="submit" name="Submit" value="ACTUALIZAR" />
  81.       </td>
  82.       <td><label>
  83.         <input type="button" name="Submit2" value="CANCELAR" onclick="document.location='inicio.php'"/>
  84.       </label></td>
  85.     </tr>
  86.   </table>
  87.   <p>&nbsp;</p>
  88. </form>
  89. </body>
  90. </html>

modificar.php

Código php:
Ver original
  1. <?php
  2. include "conexion.php";
  3. $id=$_POST['alias'];
  4. $nombre=$_POST['nombre'];
  5. $dato=$_POST['dato'];
  6. conectar();
  7. mysql_query("UPDATE password SET nombre='$nombre',dato='$dato' WHERE consecutivo='$id'");
  8. echo '<script>alert("DATOS ACTUALIZADOS CON EXITO");</script>';
  9. echo '<script>document.location="otra_pag.php";</script>';
  10. ?>

conexion.php
Código php:
Ver original
  1. <?php
  2. function conectar()
  3. {
  4.     mysql_connect("localhost","usuario","password");
  5.     mysql_select_db("base_de_datos");
  6. }
  7. function desconectar()
  8. {
  9.     mysql_close();
  10. }
  11. ?>

solo adecualo alos tu base de datos, espero te ayude, suerte