Logic to handle "DELETE Candidates ID"
[asis23-votoe-server.git] / delete_candidates_id.php
blob473e5d97099300f8738f9b4f6e25dc9b16d92e01
1 <?php
3 function handle_request($id, $input) {
4 $db = new SQLite3('database.sqlite');
5 $id = $db->querySingle("SELECT id FROM candidatos WHERE id = {$id}");
7 if (empty($id)) {
8 header('HTTP/1.1 404 Not Found');
9 } else {
10 $db->exec("DELETE FROM candidatos WHERE id = {$id}");
11 $db->exec("DELETE FROM votos WHERE candidato_id = {$id}");
14 $db->close();