PHP - Algo sencillo (borrar un registro)

 
Vista:

Algo sencillo (borrar un registro)

Publicado por Miguel (17 intervenciones) el 12/02/2010 00:15:23
Espero y alguien me pueda ayudar.

La verdad no se que tengo mal con esto: tengo el siguiente codigo para elegir el usuario que quiero borrar:

<HTML>
<HEAD>
<TITLE> Usuarios registrados </TITLE>
</HEAD>
<BODY>
<?php
$con = mysql_connect('localhost', 'xxxxxx', 'xxxxx');
if(!$con)
{ die('Could not connect:'.mysql_error()); }

$db = mysql_select_db('compras', $con);

$result = mysql_query(" SELECT * FROM usuarios ");
?>
<table border = "1">

<tr bgcolor = "#ADDFFF">
<th> <div> No. </div> </th>
<th> <div> User ID </div> </th>
<th> <div> Name </div> </th>
<th> <div> No. empleado </div> </th>
<th> <div> No. seguro </div> </th>
<th> <div> Depto. </div> </th>
<th> <div> Gerente </div> </th>
<th> <div> Created </div> </th>
</tr>
<td>
<?php

while($row = mysql_fetch_array($result))
{
$userid = $row['user'];

echo "<tr>";
print "<td> <center>" .$row['id']. "</center> </td>";

print "<td align = \"left\"> <img src= \" ../img/b_drop.png \" > <a href=\"delete.php?deluser= $userid\" > $userid </td>";

print "<td> <center>" .$row['apellido_pat']. ", " .$row['name']. " </center> </td>";
print "<td> <center>" .$row['no_empleado']. "</center> </td>";
print "<td> <center>" .$row['no_seguro']. "</center> </td>";
print "<td> <center>" .$row['depto']. "</center> </td>";
print "<td> <center>" .$row['gerente']. "</center> </td>";
print "<td> <center>" .$row['date']. "</center> </td>";
echo "</tr>";
}
?>
</td>
</table>
<?php
mysql_close($con);
?>
</BODY>
</html>

El valor, es enviado a la siguiente pagina:
<html>
<head>
<title> Delete </title>
<meta http-equiv="refresh" content="2; url=../usersdb/users.php">
</head>
<BODY>
<?php

$con = mysql_connect('localhost', 'xxxxxx', 'xxxxx');
if(!$con)
{ die('Could not connect:'.mysql_error()); }

$db = mysql_select_db('compras', $con);
//Get values
$user = $_GET["deluser"];

print $user;

$sql=" DELETE FROM usuarios WHERE user = '$user' ";

$elimina = mysql_query($sql,$con) ;

if (! $elimina)
{
die('Error: ' . mysql_error());
}
?>

<br> <br> <br>

<center> <h1> El registro ha dado de baja </h1> </center>
<center> <?php print date(DATE_RFC822); ?> </center>

<?php
mysql_close($con);
?>

</BODY>
</html>

Alguien me puede decir que es lo que esta mal en estas dos paginas. he visto 'n' paginas y aparentemente estas son las instrucciones para borrar un registro.

Agradezco de antemano la ayuda, saludos
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder