I am trying to create a button, that after inserting the name of a user in my forum it deletes him from the data base (this goes in to the backoffi, for kicking people), this is the code i got:
<?php
include 'connect.php';
include 'header.php';
echo '<h2>Command Center</h2>';
if($_SESSION['signed_in'] == false | $_SESSION['user_level'] != 1 )
{
echo 'Desculpa, mas nao tens previlegios para aceder a esta pagina.';
}
if($_SERVER['REQUEST_METHOD'] != 'POST')
{
echo '<form method="post" action="">
Nome do user a apagar: <input type="text" name="user_name" /><br />
<input type="submit" value="KICK THE BASTARD" />
</form>';
}
else
{
$sql = "DELETE FROM users(user_name)
VALUES('" . mysql_real_escape_string($_POST['user_name']) . "')";
$result = mysql_query($sql);
if(!$result)
{
echo 'Erro ao criar!' . mysql_error();
}
else
{
echo 'Categoria adicionada com sucesso!.';
}
}
include 'footer.php';
?>
But i cant seem to get it to work, this is maybe a rather simple question but i can't get around it.