Ich möchte einen datensatz löschen aber wenn ich auf remove klicke dann schickt er mich wieder auf die index seite ohne was zu löschen oder überhaupt zu fragen ob ich das gelöscht haben will!
PHP-Code:
<?
if (!isset($_SESSION['id']))
{
error("You are not logged in.", 1);
}
else
{
$number_of_servers = mysql_num_rows(mysql_query("SELECT id FROM servers WHERE ownerid = '".$_SESSION['id']."'"));
if ($number_of_servers > 0)
{
if(isset($_POST['submit']))
{
$flag = 0;
$password = md5(strip_tags(trim($_POST['password'])));
$sql = "SELECT password1 FROM users WHERE id = '".$_SESSION['id']."'";
$passwordresult = mysql_query("$sql") or die(mysql_error());
$passwordrow = mysql_fetch_array($passwordresult);
if ($password != $passwordrow['password1'])
{
error ("The password didn't match with the one in our database.", 1);
$flag = 1;
}
if ($flag != 1)
{
$sql = "DELETE FROM servers WHERE ownerid = '".$_GET['id']."' LIMIT 1";
mysql_query("$sql") or die(mysql_error());
echo "The server was removed from the list.";
}
}
else
{
?>
<p>Are you sure you want to remove your server from the list? All the current data stored about it in the database will be removed permanently.</p>
<form method='post'>
<table>
<tr>
<td colspan='2'><b>Please enter your password:</b></td>
</tr>
<tr>
<td><input type='password' name='password'></td>
<td><input type='submit' name='submit' value='Delete server permanently'></td>
</tr>
</table>
</form>
<?
}
}
else
{
error("You do not have a server on the list.", 1);
}
}
?>
Kommentar