Make `preflight` request pass okay
[asis23-votoe-server.git] / post_vote.php
blob3dff56c6cee7e71211b3eeeb71abfebbb6a21258
1 <?php
3 function handle_request($id, $input) {
4 $input = json_decode($input, true);
5 $id = $input['id'];
7 $db = new SQLite3('database.sqlite');
8 $id = $db->querySingle("SELECT id FROM candidatos WHERE id = {$id}");
10 if (empty($id)) {
11 header('HTTP/1.1 404 Not Found');
12 } else {
13 $db->exec("INSERT INTO votos (candidato_id) VALUES ({$id})");
16 $db->close();