Deletion Script is not working
Posted: Wed Feb 09, 2011 10:25 pm
Hello Everyone.
I am trying to figure out why this delete script does not want to work. I click on the delete user and all it does it take me back to the page to pick a person to delete from the database.
When I run the sql in the database it deletes the user with no problem
This is the show_user_del.php page. This is the verification page to make sure you are deleting the right person
Here is the do_delete_user.php page. Obviously the page that actually does the deleting. As I mentioned before all it does is reroute back to the pick_user.php page. without removing the person from the database
I echo the query to see what it was looking for and this is what I get
DELETE FROM auth_users WHERE id=''
Please someone help me
I am trying to figure out why this delete script does not want to work. I click on the delete user and all it does it take me back to the page to pick a person to delete from the database.
When I run the sql in the database it deletes the user with no problem
This is the show_user_del.php page. This is the verification page to make sure you are deleting the right person
Code: Select all
<?php
if (!$_POST[id]) {
header ("LOCATION: pick_user.php");
exit;
}
require('../includes/auth_user.php');
//build and issue query
$sql = "SELECT * FROM $table WHERE id = '$_POST[id]'";
$result = mysql_query($sql, $connection) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$f_name = $row['f_name'];
$l_name = $row['l_name'];
$username = $row['username'];
$password = $row['password'];
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Add Classified Ad</title>
</head>
<body>
<h2><em>Delete user from Database</em></h2>
<h3>User being deleted <?php echo "$f_name $l_name"; ?></h3>
<form method="POST" action="do_delete_user.php">
<input type="hidden" name="id" value="<?php echo "$_POST[id]"; ?>" />
<input type="hidden" name="f_name" value="<?php echo "$f_name"; ?>" />
<input type="hidden" name="l_name" value="<?php echo "$l_name"; ?>" />
<p> <strong>Name:</strong> <?php echo "$f_name $l_name"; ?>
</p>
<p> <strong>Username:</strong> <?php echo "$username"; ?>
</p>
<p> <strong>Password:</strong> <?php echo "$password"; ?>
</p>
<p>
<input type="submit" name="submit" id="name" value="Delete User" />
</p>
</form>
<p><a href="../admin_menu.php">Return to Administration Menu</a></p>
</body>
</html>Here is the do_delete_user.php page. Obviously the page that actually does the deleting. As I mentioned before all it does is reroute back to the pick_user.php page. without removing the person from the database
Code: Select all
<?php
if (!$_POST[id]) {
header ("LOCATION: pick_user.php");
exit;
}
require('../includes/auth_user.php');
$sql = "DELETE FROM $table WHERE id='$_POST[id]'";
$result = mysql_query($sql, $connection) or die(mysql_error());
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<h1>User has been removed</h1>
<?php echo "$sql"; ?><?php echo "$result"; ?>
<h2><em>User <?php echo "$_POST[f_name] $_POST[l_name]"; ?> has been deleted
from the <?php echo "$table"; ?> table</em></h2>
<p><a href="pick_user.php">Delete another person</a></p>
<p><a href="../admin_menu.php">Administration Menu</a></p>
</body>
</html>DELETE FROM auth_users WHERE id=''
Please someone help me