<?php
function delReponse($r_id) {
$bdd = new PDO($arrayConnection);
$reponse = $bdd->prepare('DELETE FROM `topics_reponses` WHERE `id`=?');
$reponse->execute(array($r_id));
}
?>
<script>
var res = window.confirm('Are you sure you want to delete this message?');
if (res) {
document.write("<?php delReponse($r_id)?>");
alert("Le message a bien été supprimé.");
} else
alert("Le message n'a PAS été supprimé.");
window.close();
</script>
Even if you click on "cancel", the php function which deletes an entry in the DB is executed.