este es el codigo del admin.php
Código PHP:
<?php
// *************************************************************************************************
//
// *************************************************************************************************
//
session_start();
include "level4_check.php";
$msg = "Para editar un permiso haga clic sobre un usuario.";
if(isset($_POST['Amend'])) {
$username = $_POST['username'];
$userpass = $_POST['userpass'];
$userlevel = $_POST['userlevel'];
$useremail = $_POST['useremail'];
$userafiliacion = $_POST['userafiliacion'];
$userid = $_POST['userid'];
$result = mysql_query("Update login_table set user_name='$username', user_pass='$userpass', user_email='$useremail',user_afiliacion='$userafiliacion', user_level='$userlevel' where userid=".$_POST['userid']);
$msg = "Record is updated<br>Para editar un permiso haga clic sobre un usuario";
$edit = "";
}
if(isset($_POST['Submit']))
{
$total = $_POST['total'];
$td = 0;
$i = 0;
for($i = 1; $i <= $total; $i++)
{
if(isset($_POST["d$i"]))
{
mysql_query("DELETE FROM login_table WHERE userid=".$_POST["d$i"],$con);
$td++;
}
}
$msg = "$td record(s) deleted!<br>Para editar un permiso haga clic sobre un usuario";
}
if ($order == "") {$order = "userid";}
$result = mysql_query("Select * from login_table ORDER BY '$order'",$con);
$num = mysql_num_rows($result);
$n = 0;
?>
<html>
<head>
<title>Admin</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
background-image: url(imagenes/fondoweb.jpg);
}
.Estilo1 {color: #FFFFFF}
.Estilo3 {color: #CCCCCC}
a:link {
color: #02B8DD;
text-decoration: none;
}
a:visited {
color: #999999;
text-decoration: none;
}
a:hover {
color: #018AA7;
text-decoration: none;
}
a:active {
text-decoration: none;
}
-->
</style></head>
<body bgcolor="#CBC9F5">
<h3> </h3>
<h3 class="Estilo1">Administrador de permisos de Usuarios Protegemos G.C </h3>
<form name="form1" method="post" action="">
<p class="smallTextBlack"><?php echo $msg; ?><br>
<span class="Estilo1">Descripción de Niveles :<BR>
1 = (Restricción Alta - acceso a pantallas comunes Usuario Protegemos Limitado)<BR>
2 = (Restricción Media-Acceso a pantallas de nivel 2 y 1 Usuario protegemos Plata)<BR>
3 = (Restricción Baja- Acceso a Niveles 3, 2 , 1 usuario protegemos Gold)<BR>
4 = (Nivel unicamente designado para el Administrador u Webmaster )</span></p>
<p class="smallTextBlack"> </p>
<table width="100%" border="0" cellpadding="1" cellspacing="1" bordercolor="#000000">
<tr bgcolor="#A39FF6" class="standardText">
<td width="5%" bgcolor="#2F9B23"><div align="center">DELETE</div></td>
<td width="5%" bgcolor="#2F9B23"><div align="center"><a href="admin.php?order=userid" class="standardText Estilo1">ID</a></div></td>
<td width="20%" bgcolor="#2F9B23"><div align="center"><a href="admin.php?order=user_name" class="standardText Estilo1">USUARIO</a> </div></td>
<td width="20%" bgcolor="#2F9B23"><div align="center" class="Estilo1">CONTRASEÑA </div></td>
<td width="20%" bgcolor="#2F9B23"><div align="center" class="Estilo1">AFILIACION </div></td>
<td width="15%" bgcolor="#2F9B23"><div align="center"><a href="admin.php?order=user_level" class="standardText Estilo1">NIVEL DE ACCESO</a></div></td>
<td width="20%" bgcolor="#2F9B23"><div align="center"><a href="admin.php?order=user_email" class="standardText Estilo1">EMAIL</a></div></td>
<td width="10%" bgcolor="#2F9B23"><div align="center" class="Estilo1">IP DE REGISTRO </div></td>
<td width="10%" bgcolor="#2F9B23"><div align="center"><a href="admin.php?order=date" class="standardText Estilo1">FECHA DE REGISTRO</a> </div></td>
</tr>
<?php while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
$n++;
?>
<tr>
<td width="5%"><div align="center">
<input type="checkbox" name="d<?php echo $n;?>" value="<?php echo $row['userid'];?>">
</div></td>
<td width="5%"><?php echo $row['userid'];?></td>
<td width="20%"><a href="admin.php?edit=<?php echo $row['user_name']?>"><?php echo $row['user_name'];?></a></td>
<td width="20%"><?php echo $row['user_pass'];?></td>
<td width="20%"><?php echo $row['user_afiliacion'];?></td>
<td width="5%"><center><?php echo $row['user_level'];?></center></td>
<td width="20%"><?php echo $row['user_email'];?></td>
<td width="20%"><?php echo $row['user_ip'];?></td>
<td width="20%"><?php echo $row['date'];?></td>
</tr>
<?php
}?>
</tr>
<div align="center"></div>
</table>
<input type="submit" name="Submit" value="Delete"> <input name="total" type="hidden" id="total" value="<?php echo $n?>">
<p> </p></form>
<!-- FORM FOR AMENDMENT -->
<?php if ($edit) {$msg = "Edit record below";
$result = mysql_query("Select * from login_table WHERE user_name = '$edit'",$con);
$row = mysql_fetch_array($result)
?>
<form name="form2" method="post" action="">
<div class="smallTextBlack">Edit user :-</div>
<table width="100%" border="0" cellpadding="1" cellspacing="1" bordercolor="#000000">
<tr bgcolor="#999999" class="standardText">
<td bgcolor="#000000"><div align="center" class="Estilo1">ID</div></td>
<td bgcolor="#333333"><div align="center" class="Estilo1">USUARIO </div></td>
<td bgcolor="#333333"><div align="center" class="Estilo1">CONTRASEÑA</div></td>
<td bgcolor="#333333"><div align="center" class="Estilo1">AFILIACION</div></td>
<td width="20%" bgcolor="#333333"><div align="center" class="Estilo1">NIVEL DE ACCESO </div></td>
<td bgcolor="#000000"><div align="center" class="Estilo1">EMAIL</div></td>
<td bgcolor="#000000"><div align="center" class="Estilo1">IP DE REGISTRO </div></td>
<td bgcolor="#000000"><div align="center" class="Estilo1">FECHA DE REGISTRO </div></td>
</tr>
<tr>
<td width="5%"><center><?php echo $row['userid'];?></center></td>
<td width="15%"><input type="username" name="username" value="<?php echo $row['user_name'];?>"></a></td>
<td width="35%"><input type="userpass" name="userpass" value="<?php echo $row['user_pass'];?>" size="40"></td>
<td width="35%"><input type="userafiliacion" name="userafiliacion" value="<?php echo $row['user_afiliacion'];?>" size="40"></td>
<td width="15%"><select name="userlevel"> <option>1</option>
<option>2</option>
<option>3</option>
<option>4</option></select> SET AT LEVEL: <?php echo $row['user_level'];?></td>
<td width="20%"><input type="useremail" name="useremail" value="<?php echo $row['user_email'];?>"></td>
<td width="10%"><?php echo $row['user_ip'];?></td>
<td width="10%"><?php echo $row['date'];?></td>
</tr>
</table>
<input type="hidden" name="userid" value="<?php echo $row['userid'];?>">
<input type="Submit" name="Amend" value="Update">
<label></label>
</form>
<?php }?>
<p><a href="index.php">:: Ir a la pagina principal</a> <a href="adduser.php">:: Add usuario :: </a><a href="logout.php" class="Estilo3">Salir del administrador :: </a> </p>
</body>
</html>