I am trying to create a script that deletes the image from the database and the folder, but the problem is that it is only deleting from the DB and not from the folder.
Tabela equipes
id, nome, foto
Here is the PHP I'm using:
$id = $_GET["id"];
if($_SERVER["REQUEST_METHOD"] == "POST"){
if(isset($_POST["deletar"])){
$sqlDeletar = $pdo->prepare("DELETE FROM equipes WHERE id = :id");
$sqlDeletar->bindValue(":id", $id);
$sqlDeletar->execute();
$dadosDeletar = $sqlDeletar->fetchObject();
unlink("../upload/".$dadosDeletar->foto);
echo "Aqui é o link de redirecionar.";
}else{
if(isset($_POST["nao"])){
echo "Aqui é o link de redirecionar.";
}
}
}
And here's the form:
<form action="" method="post" enctype="multipart/form-data">
<label>
<input type="submit" name="deletar" value="Excluir">
<input type="submit" name="nao" value="Não excluir">
</label>
</form>