pongo todo el codigo, esta hecho de esa forma porque los campos seleccionados en checks se borran solamente, pero no me resulta que pregunte primero si realmente desea borrar
Código PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" version="-//W3C//DTD XHTML 1.1//EN" xml:lang="en"><head><title>WIDEFENSE</title>
<title>Company Bulletin Board</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />
<style type="text/css">
td {
font-family:Arial, Helvetica, Verdana, sans-serif;
font-size: 12px;
line-height: 21px;
}
#menu_items li {
position:relative;
display: block;
float: left;
height: 35px;
background-image: url(http://wtheme.webme.com/img/menu_s.gif);
background-repeat: no-repeat;
margin-top: -8px;
padding-top: 8px;
}
#img_logo {
border:0px;
}
</style>
<link href="http://wtheme.webme.com/img/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
var activateFCK = false;
if (screen.width<1500) {
document.write('<link href="http://wtheme.webme.com/img/style_1024.css" rel="stylesheet" type="text/css">');
}
if (screen.width<900) {
document.write('<link href="http://wtheme.webme.com/img/style_800.css" rel="stylesheet" type="text/css">');
}
var CONFIG__USERADMIN_AJAX_TIMEOUT = 60000;
var CONFIG__USERADMIN_LOADING_FCKEDITOR_TIMEOUT = 10000;
var fckLoaded = false;
</script>
<script type="text/javascript">
var lastid = 1;
function formfocus(id) {
if (lastid !== 0)
{
document.getElementById('form_row'+lastid).className='formrow';
document.getElementById('form_row'+id).className='formrow_ac';
}
lastid = id;
}
function formblur(id) {
document.getElementById('form_row'+id).className='formrow';
}
</script>
<style type="text/css">
body,td,th {
font-family: "frutiger Linotype";
font-size: 14px;
color: #000;
font-weight: bold;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script>
function refrescar()
{
window.location = "agregapost.php";
}
function agregar(){
window.location = "agregapost.php"
}
</script>
</head><body>
</script>
<a name="top"></a>
<div id="header">
<div style="width: 717px;"><br>
<a href="superdemo.php" style="font:'frutiger Linotype'; font-size:14px">Administrador Grafico</a>
<a href="admusuarios.php" style="font:'frutiger Linotype'; font-size:14px" >Administrador Usuarios</a>
<a href="admpost.php" style="font:'frutiger Linotype'; font-size:14px">Administrador Post it</a>
<a href="vista.php" style="font:'frutiger Linotype'; font-size:14px">Vista</a>
<a href="logout.php" style="font:'frutiger Linotype'; font-size:14px">Log Out</a>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><script type="text/javascript">
var progress_image='<img src="http://wtheme.webme.com/images/progress.gif" id="progress_src">';
</script></div>
</div>
</div>
<div id="menu_r"></div>
</div>
<?php
require 'connect.php';
$sql="SELECT * FROM usuarios";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
?>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td><form name="form1" method="post" action="">
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#FFFFFF"> </td>
<td colspan="4" bgcolor="#FFFFFF"><strong>Mantenedor De Usuarios</strong> </td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF"></td>
<td align="center" bgcolor="#FFFFFF"><strong>Rut</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Usuario</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Nombre</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Mail</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Empresa</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Grupo</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Tipo Usuario</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Fono</strong></td>
</tr>
<?php
$i=0;
while($xrows=mysql_fetch_row($result)){
$i++;
?>
<tr>
<td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $xrows[3]; ?>"></td>
<td bgcolor="#FFFFFF"><?php echo $xrows[3]; ?><input type="hidden" name="campo_<?php echo $i; ?>_3" value="<?php echo $xrows[3]; ?>"</td>
<td bgcolor="#FFFFFF"><textarea name="campo_<?php echo $i; ?>_0" cols="6"><?php echo $xrows[0]; ?></textarea></td>
<td bgcolor="#FFFFFF"><textarea name="campo_<?php echo $i; ?>_2" cols="15"><?php echo $xrows[2]; ?></textarea></td>
<td bgcolor="#FFFFFF"><textarea name="campo_<?php echo $i; ?>_5"><?php echo $xrows[4]; ?></textarea></td>
<td bgcolor="#FFFFFF"><textarea name="campo_<?php echo $i; ?>_6" cols="5"><?php echo $xrows[5]; ?></textarea></td>
<td bgcolor="#FFFFFF"><textarea name="campo_<?php echo $i; ?>_7" cols="5"><?php echo $xrows[6]; ?></textarea></td>
<td bgcolor="#FFFFFF"><textarea name="campo_<?php echo $i; ?>_8" cols="8"><?php echo $xrows[7]; ?></textarea></td>
<td bgcolor="#FFFFFF"><textarea name="campo_<?php echo $i; ?>_9" cols="5"><?php echo $xrows[8]; ?></textarea></td>
</tr>
<?php
}
?>
<tr>
<td colspan="5" align="center" bgcolor="#FFFFFF">
<input name="Input" type="button" value="Agregar" onClick="location.href='registrar.php'">
<input name="delete" type="submit" id="delete" value="Borrar" onClick="return borrar();" >
<input name="modifica" type="submit" id="modifica" value="Modificar">
<input name="reset" type="submit" id="reset" value="Reset">
<input name="button" type="button" onClick="location.href='administrador.php'" value="Salir">
</td>
</tr>
<script>
function borrar()
{
if ( confirm("Seguro que deseas eliminar el registro?") ) {
return true;
<?php
// Check if delete button active, start this
if(isset($_POST['delete'])) {
$delete = $_POST["checkbox"];
$cantidad = count($delete);
for ($i="0"; $i<$cantidad; $i++) {
$del_id = $delete[$i];
$sql = "DELETE FROM usuarios WHERE rut = '". $del_id ."' ";
$result = mysql_query($sql);
echo '<meta http-equiv="refresh" content="3;URL=admusuarios.php">';
}
if($result){
echo '<meta http-equiv="refresh" content="50;URL=admusuarios.php">';
}
}
?>
}
}
</script>
<?php
if(isset($_POST['reset'])) {
$checkbox = isset($_POST['checkbox']);
$sDelIDs = $_POST["checkbox"];
$sQry = "UPDATE usuarios set pass='widefense' WHERE rut IN ('" . $sDelIDs . "')";
$result=mysql_query($sQry);
if($result){
echo '<meta http-equiv="refresh" content="3;URL=admusuarios.php">';
}
}
if(isset($_POST['modifica'])){
echo "Modificando ...";
$sql = "select count(*) from usuarios";
$result = mysql_query($sql);
if($result){
$cuantos = mysql_fetch_row($result);
echo $cuantos[0];
if($cuantos[0] > 0){
for($i=1;$i<=$cuantos[0];$i++){
$sql = "Update usuarios ";
$sql .= " set usuario = '".$_POST["campo_".$i."_0"]."',";
// $sql .= " pass = '".$_POST["campo_".$i."_1"]."',";
$sql .= " nombre = '".$_POST["campo_".$i."_2"]."',";
// $sql .= " password= '".$_POST["campo_".$i."_4"]."',";
$sql .= " mail = '".$_POST["campo_".$i."_5"]."',";
$sql .= " empresa = '".$_POST["campo_".$i."_6"]."',";
$sql .= " grupo = '".$_POST["campo_".$i."_7"]."',";
$sql .= " tipo_usuario= '".$_POST["campo_".$i."_8"]."',";
$sql .= " fono = '".$_POST["campo_".$i."_9"]."'";
$sql .= " where rut = '".$_POST["campo_".$i."_3"]."'";
$result=mysql_query($sql);
}
if($result){
echo '<meta http-equiv="refresh" content="3;URL=admusuarios.php">';
}
}
}
}
mysql_close();
?>
</table>
</form>
</td>
</tr>
</table>
<div id="content_inner">
<h1></h1>
<p />
<div id="content_text">
<div id="signup">
<div id="landing_headline_outer">
<div id="signup_headline">
<h1>Company Bullentin Board</h1>
</div>
</div>
<link rel="StyleSheet" href="demo/css/style2.css" type="text/css">
<link href="css/login.css" rel="stylesheet" type="text/css" />
<div align="right">
<form action="demo/validar_usuario.php" action="ajax/post.php" method="post" >
<link href="css/login.css" type="text/css" />
<p> </p>
<p align="right">
<p> </p>
</p>
</form>
</div>
<div style="clear: both;"></div>
<div id="landing_footer_outer">
<div id="landing_footer">
<div style="font:'frutiger Linotype'" id="landing_buttontext">Innovar es nuestra misión...</div>
<input style="font:'frutiger Linotype'" type="button" value="Vista Post It" id="landing_button" onClick="document.location='vista.php';" />
</div>
</div>
</div>
</div>
<!-- Google Code for DEFAULT Conversion Page -->
<script language="JavaScript" type="text/javascript">
var google_conversion_type = 'landing';
var google_conversion_id = 1069529469;
var google_conversion_language = "de";
var google_conversion_format = "1";
var google_conversion_color = "FFFFFF";
</script>
<script language="JavaScript" src="http://www.googleadservices.com/pagead/conversion.js"></script>
<noscript>
<img src="http://www.googleadservices.com/pagead/conversion/1069529469/extclk?script=0" alt="a" width="1" height="1" border="0">
</noscript>
</div>
<p> </p>
</body>
</html>