Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/06/2011, 13:55
karenlorenadg
 
Fecha de Ingreso: octubre-2008
Ubicación: Colombia
Mensajes: 448
Antigüedad: 15 años, 6 meses
Puntos: 2
Busqueda Modificar Registros con PHP

Hola a todos, tengo un sistema de registro de usuarios, del cual al generar el resultado con la busqueda (consulta) me muestra en pantalla todos los registros, le implementé dos botones, uno de borrar y otro de modificar el usuario, el boton de eliminar me funciona correctamente, pero el de modificar no, tengo 7 campos que modificar, el sistema no me presenta ningun error de sintaxis, todo funciona bien, pero solo con 3 campos de esos 7 ya que si les modifico los 7 campos no pasa nada, pero en cambio si le elimino 4 esos tres restante modifican correctamente.

Esto me tiene preocupada y qusiera saber porque ocurre esto?

Estos son los archivos que utilizo.

Un archivo modificar.php con el siguiente codigo que me muestra en pantalla los datos listos a modificar

Código PHP:
<?php
require_once("conexion/conexion.php");
$sql="select * from usuarios where id=".$_GET["id"]."";
$res=mysql_query($sql,$con);
?>
<html>
<head>
<title>Sistema de Gestion de Usuarios v. 2.0 - Modificar datos de Usuarios</title>
<script language="javascript" type="text/javascript" src="modjs/funciones.js"></script>
</head>

<body onLoad="limpiar()">
<?php
if ($reg=mysql_fetch_array($res))
{
?>
<form action="edit.php" method="post" name="form">
<table align="center" width="400">
<tr>
<td valign="top" align="center" width="400" colspan="2">
<h3>Modificar datos de Usuarios</h3>
</td>
</tr>

<tr>
<td align="right" valign="top" width="200"><strong>
Documento
</strong></td>
<td valign="top" align="left" width="200">
  <strong>
  <input type="text" name="documento" value="<?php echo $reg["documento"];?>" />
  </strong></td>
</tr>

<tr>
<td align="right" valign="top" width="200"><strong>
Apellidos
</strong></td>
<td valign="top" align="left" width="200">
<input type="text" name="apellidos" value="<?php echo $reg["apellidos"];?>" />
</td>
</tr>

<tr>
<td align="right" valign="top" width="200"><strong>
Nombre
</strong></td>
<td valign="top" align="left" width="200">
<input type="text" name="nombres" value="<?php echo $reg["nombres"];?>" />
</td>
</tr>

<tr>
<td align="right" valign="top" width="200"><strong>
  Direcci&oacute;n
</strong></td>
<td valign="top" align="left" width="200">
<input type="text" name="direccion" value="<?php echo $reg["direccion"];?>" />
</td>
</tr>

<tr>
<td align="right" valign="top" width="200"><strong>
Zona
</strong></td>
<td valign="top" align="left" width="200">
<input type="text" name="zona" value="<?php echo $reg["zona"];?>" />
</td>
</tr>

<tr>
<td align="right" valign="top" width="200"><strong>
Ayuda
</strong></td>
<td valign="top" align="left" width="200">
<input type="text" name="ayuda" value="<?php echo $reg["ayuda"];?>" />
</td>
</tr>

<tr>
<td align="right" valign="top" width="200"><strong>
  L&iacute;der
</strong></td>
<td valign="top" align="left" width="200">
<input type="text" name="lider" value="<?php echo $reg["lider"];?>" />
</td>
</tr>

<tr>
<td valign="top" align="center" width="400" colspan="2">
<input type="hidden" name="id" value="<?php echo $_GET["id"];?>">
<input type="button" value="Volver" title="Volver" onClick="history.back();" />
&nbsp;&nbsp;||&nbsp;&nbsp;
<input type="button" value="Modificar" title="Modificar" onClick="validar()" />
</td>
</tr>

</table>
</form>
<?php
}
?>
</body>
</html>
y el archivo que procesa los datos a actualizar que que se llama

edit.php

Código PHP:
<?php
//print_r($_POST);
require_once("conexion/conexion.php");
$sql="update usuarios
set
documento='"
.$_POST["documento"]."',
apellidos='"
.$_POST["apellidos"]."',
nombres='"
.$_POST["nombres"]."'
direccion='"
.$_POST["direccion"]."'
zona='"
.$_POST["zona"]."'
ayuda='"
.$_POST["ayuda"]."'
lider='"
.$_POST["lider"]."'
where
id="
.$_POST["id"]."";
//echo $sql;
$res=mysql_query($sql,$con);
echo 
"<script type=''>
    alert('Los datos del Usuario fueron modificados correctamente');
    window.location='resultados.php';
</script>"
;
?>
Espero que alguien pueda ayudarme, no encuentro explicacion logica a este impace.
__________________
Desarrollo de Aplicaciones de Escritorio, Sitios Web, Audio y Video en SISGUS