Código PHP:
<?php
echo"<html>\n";
echo"<head>\n";
echo"<title>Modificarauto</title>\n";
echo"</head>\n";
$enlace = mysql_connect("localhost", "root", "") or die("No pudo conectarse : " . mysql_error());
echo "Conexión exitosa";
mysql_select_db("automotora") or die("No pudo seleccionarse la BD.");
if (isset($btnmodificar))
{
if (!$txtnumero)
{
echo "Debe ingresar valores para el numero de usuario. Vuelva atras con su browser e ingrese los datos.\n";
exit;
}
if (!$txtnombre)
{
echo "Debe ingresar valores para el nombre de ususario. Vuelva atras con su browser e ingrese los datos.\n";
exit;
}
//if (!$grupo)
//{
// echo "Debe ingresar el grupo de usuario. Vuelva atras con su browser e ingrese los datos.\n";
// exit;
//}
if (!$txtapellido)
{
echo "Debe ingresar el apellido. Vuelva atras con su browser e ingrese los datos.\n";
exit;
}
if (!$txtlogin)
{
echo "Debe ingresar el login. Vuelva atras con su browser e ingrese los datos.\n";
exit;
}
if (!$txtpas)
{
echo "Debe ingresar el pas. Vuelva atras con su browser e ingrese los datos.\n";
exit;
}
$sql = "
UPDATE usuario SET ID_USUARIO=".$txtnumero.",
ID_GRUPO=".$grupo.",
NOMBRE='".$txtnombre."',
APELLIDO='".$txtapellido."',
LOGIN='".$txtlogin."',
PAS='".$txtpas."',
WHERE ID_USUARIO='$txtnumero'
;
";
echo "SQL GENERADO:$sql<br>\n";
//echo "SQL GENERADO:$sqlq<br>\n";
$ress=mysql_db_query("automotora",$sql);
if (!$ress)
{
echo "<center><h3><b>no se pudo modificar en la base de datos</b></h3></center>\n<br>";
echo "<center><h3><b>vuelva atras e intente de nuevo</b></h3></center><br>";
}
else
{
//echo"<center><h3><b>El registo fue modificado en la base de datos</b></h3></center><br><br>";
mysql_close();
//echo "<a href='../filtro.php'><center><h3><b>ver listado</b></h3></center></a>";
//echo "<a href='../subir.php'><center><h3><b>subir la foto</b></h3></center></a>";
}
}
else
{
echo"<body>\n";
echo"<center><h2><b>MODIFICAR USUARIO</b></h2></center>\n";
echo"<form action='$_SERVER' method='post' name=''>\n";
$sql ="SELECT * FROM USUARIO WHERE ID_USUARIO='$txtnumero'";
$res = mysql_query($sql) or die("La consulta falló: " . mysql_error());
$num=mysql_numrows($res);
for($i=0;$i<$num;$i++)
{
$id_usuario=mysql_result($res,$i,"ID_USUARIO");
$id_grupo=mysql_result($res,$i,"ID_GRUPO");
$nombre=mysql_result($res,$i,"NOMBRE");
$apellido=mysql_result($res,$i,"APELLIDO");
$login=mysql_result($res,$i,"LOGIN");
$pas=mysql_result($res,$i,"PAS");
}
echo"<center>\n";
echo"<table border='0' width='100' height='391'>\n";
echo"<tr> \n";
echo"<td width='33%' height='19'><font face='Verdana'><b>ID_USUARIO</b></font></td>\n";
echo"<td width='33%' height='19' align='center'><font face='Verdana'><b>:</b></font></td>\n";
echo"<td width='34%' height='19'><input name='txtid' type='text' value='$id_usuario'size='20' maxlength='20'></td>\n";
echo"</tr>\n";
$sql1 = "SELECT * FROM grupo where ID_GRUPO=$id_grupo";
$res1 = mysql_query($sql1) or die("La consulta falló: " . mysql_error());
$num1=mysql_numrows($res1);
for ($i=0; $i<$num1; $i++)
{
$txtid_grup=mysql_result($res1,$i,"ID_GRUPO");
}
$sql = "SELECT * FROM GRUPO";
$res = mysql_query($sql) or die("La consulta falló: " . mysql_error());
$num=mysql_numrows($res);
echo"<tr> \n";
echo"<td width='33%'><font face='Verdana'><b>GRUPO</b></font></td>\n";
echo"<td width='33%' align='center'><font face='Verdana'><b>:</b></font></td>\n";
echo"<td width='34%' align='left'>";
echo"<select name='cmblocal' size='1' id='cmblocal'>\n";
while ($row=mysql_fetch_array($res))
{
echo "<option value=\"".$row['txtid_grup']."\">".$row['GRUPO']."</option>\n";
}
echo"</select>\n";
echo"<tr>\n";
echo"<td width='33%'><font face='Verdana'><b>NOMBRE</b></font></td>\n";
echo"<td width='33%' align='center'><font face='Verdana'><b>:</b></font></td>\n";
echo"<td width='34%' align='center'> <div align='left'>\n";
echo"<input name='txtnombre' type='text' value='$nombre' size='15' maxlength='10'>\n";
echo"</div></td>\n";
echo"</tr>\n";
echo"<tr> \n";
echo"<td><strong><font face='Verdana'>APELLIDO</font></strong></td>\n";
echo"<td align='center'><strong><font face='Verdana'>:</font></strong></td>\n";
echo"<td align='center'><div align='left'> \n";
echo"<input name='txtapellido' type='text' value='$apellido' size='20' maxlength='20'>\n";
echo"</div></td>\n";
echo"</tr>\n";
echo"<tr> \n";
echo"<td width='33%'><font face='Verdana'><b>LOGIN </b></font></td>\n";
echo"<td width='33%' align='center'><font face='Verdana'><b>:</b></font></td>\n";
echo"<td width='34%' align='center'><div align='left'> \n";
echo"<input name='txtlogin' type='text' value='$login' size='20' maxlength='10'>\n";
echo"</div></td>\n";
echo"</tr>\n";
echo"<tr> \n";
echo"<td width='33%'><font face='Verdana'><b>PAS</b></font></td>\n";
echo"<td width='33%' align='center'><font face='Verdana'><b>:</b></font></td>\n";
echo"<td width='34%' align='center'><div align='left'> \n";
echo"<input name='txtpas' type='text' value='$pas' size='20' maxlength='10'>\n";
echo"</div></td>\n";
echo"</tr>\n";
echo"<tr> \n";
echo"<td width='100%' colspan='3' height='25'> <p align='center'>\n";
echo"<input type='submit' value='Modificar' name='btnmodificar'>\n";
echo "<input type='hidden' name='txtnumero' value='$txtnumero'>";
echo"</td>\n";
echo"</tr>\n";
echo"</table>\n";
echo"</center>\n";
echo"</form>\n";
echo"</body>\n";
echo"</html>\n";
}
?>
codigo actual que tengo en la pagina