diff --git a/static/php/db/database.db b/static/php/db/database.db new file mode 100644 index 0000000..e0b6962 Binary files /dev/null and b/static/php/db/database.db differ diff --git a/static/php/insert.php b/static/php/insert.php new file mode 100644 index 0000000..48c8126 --- /dev/null +++ b/static/php/insert.php @@ -0,0 +1,83 @@ +db = new PDO('sqlite:'.$file); + } catch(PDOException $e) { + error_log($e->getMessage(), 3, 'php://stderr'); + } + } + + function query($sql,$attr){ + $stmt = $this->db->prepare($sql); + try { + $stmt->execute($attr); + } catch (PDOException $e) { + echo $e->getMessage(); + } + return $stmt; + } +} + +function createquery($form){ + $date = date("Y-m-d H:i:s"); + + switch($form){ + case "skola": + $query = " + insert into skola + (id,datum,instituce,kraj,adresa,jmeno,email,telefon,pocet_skupin,pocet_deti,vek_deti,pece,poznamka) + values (?,?,?,?,?,?,?,?,?,?,?,?,?) + "; + $values = [ + NULL, + $date, + $_REQUEST["instituce"], + $_REQUEST["kraj"], + $_REQUEST["adresa"], + $_REQUEST["jmeno"], + $_REQUEST["email"], + (empty($_REQUEST["telefon"]) ? "" : $_REQUEST["telefon"]), + $_REQUEST["pocet_skupin"], + $_REQUEST["pocet_deti"], + $_REQUEST["vek_deti"], + $_REQUEST["pece"], + (empty($_REQUEST["poznamka"]) ? "" : $_REQUEST["poznamka"]) + ]; + break; + case "dobrovolnik": + $query = " + insert into dobrovolnik + (id,datum,jmeno,email,telefon,studijni_program,obor,kraj,cas,vek_deti,distancni_vyuka,uznani_praxe,poznamka) + values (?,?,?,?,?,?,?,?,?,?,?,?,?) + "; + $values = [ + NULL, + $date, + $_REQUEST["jmeno"], + $_REQUEST["email"], + (empty($_REQUEST["telefon"]) ? "" : $_REQUEST["telefon"]), + $_REQUEST["studijni_program"], + $_REQUEST["obor"], + $_REQUEST["kraj"], + $_REQUEST["cas"], + $_REQUEST["vek_deti"], + $_REQUEST["distancni_vyuka"], + $_REQUEST["uznani_praxe"], + (empty($_REQUEST["poznamka"]) ? "" : $_REQUEST["poznamka"]) + ]; + break; + } + return [$query,$values]; +} + +$db = new database("./db/database.db"); + +$query = createquery($_REQUEST["form"]); +$db->query("$query[0]",$query[1]); + +$refer = (!empty($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "/"); +header("Location: ".$refer); diff --git a/templates/shortcodes/form_dobrovolnik.html b/templates/shortcodes/form_dobrovolnik.html index 8b9fb71..00ab8d6 100644 --- a/templates/shortcodes/form_dobrovolnik.html +++ b/templates/shortcodes/form_dobrovolnik.html @@ -1,4 +1,5 @@ -
+ +
@@ -57,6 +58,10 @@
+
+ + +
diff --git a/templates/shortcodes/form_skola.html b/templates/shortcodes/form_skola.html index 7c031bf..fd1b3ba 100644 --- a/templates/shortcodes/form_skola.html +++ b/templates/shortcodes/form_skola.html @@ -1,4 +1,5 @@ - + +