Html
<html>
<body>
<form action="encomenda_apagar.php" method="POST">
<br><br>
<label class="sr-only" for="inputHelpBlock"></label>
<b>INSIRA O SEU USERNAME:</b> <br><br>
<input type="text" name="user">
<br>
<center><input type="submit" value="Eliminar"></center>
<br>
</form>
</body>
</html>
PHP
<script language="javascript">
<!--
function myFunction(a) {
alert(a);
}
</script>
<?php
ini_set ('default_charset','utf-8');
$link = mysqli_connect("localhost", "root", "", "bd_calcadocharme");
$id=$_GET['user'];
$sql="DELETE FROM cliente WHERE user='$id'";
$result = mysqli_query($link,$sql);
if ($result && mysqli_affected_rows($link)){
echo "<script> myFunction('Cliente elimado com sucesso'); </script>";
header('refresh:0 ; url=escrever.html');
} elseif ($result && !mysqli_affected_rows($link)){
echo "<script> myFunction('Esse cliente nao existe !'); </script>";
header('refresh:0 ; url=escrever.html');
} elseif (!$result){
echo "<script> myFunction('Erro na query!'); </script>";
header('refresh:0 ; url=escrever.html');
}
?>
Errors: Notice: Undefined index: user in F: \ XAMPP \ htdocs \ PAPBRUNO \ PAPBRUNO \ order_apagar.php on line 15
And I do not understand why.
When I try to delete someone who does not exist, the "query error" message appears and MUST APPEAR "This client does not exist" And even when I put someone that exists, it does not delete