From 49bacd40109091d73256e73bf0cf4536d00f1647 Mon Sep 17 00:00:00 2001 From: Emil Miler Date: Sat, 14 Nov 2020 19:36:00 +0100 Subject: [PATCH] =?UTF-8?q?Vkl=C3=A1d=C3=A1n=C3=AD=20do=20datab=C3=A1ze?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/php/db/database.db | Bin 0 -> 32768 bytes static/php/insert.php | 83 +++++++++++++++++++++ templates/shortcodes/form_dobrovolnik.html | 7 +- templates/shortcodes/form_skola.html | 3 +- 4 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 static/php/db/database.db create mode 100644 static/php/insert.php diff --git a/static/php/db/database.db b/static/php/db/database.db new file mode 100644 index 0000000000000000000000000000000000000000..e0b69629cfd4ce6a4305463250e5bc1c5232e5e9 GIT binary patch literal 32768 zcmeI)Z%^7l90%}L6e=kAWT{VJ=Y(}+R*Xt9e ztxF4%EK4smO_HQEPYO>-o~C&E#?v%UqlY|tbICF-J=*v_pKVGrnbSmeI=eUjYwmI8 zG;^FezN8k4AOHafKmY;|fB*!pNg(rE7SB`phgvMkM+HV&J?iiES|+3Yff=rvPoItF zq+ZqalA&ux>19RN^5YxiwdM3|-nR0y<*K1?=yk1HGqh@>Qqi{R<;_yPslC>lTB%{w z%2nRjrd~C)Mzy@%(ARiHi?E=dpEdM%ywX`kk>BZ4$BoISePZ`w@)_;XUDp|whz5KX zSa!#;&4K5B@JQTexGmR?GZjP z#3HekNUE!=a&r_7#DwzcUO=6;2oBNJ>2q=5Lg6x>rgV+hTp5O|MZP$ExS3K97i+2H zjyR9x8FRIis;ctWkHe1>JqWuob*|}rnD>w7i|zQ#Ws$mJ7Eg#RmxP@GjorPA!DL>H$%1&n0|F3$00bZa0SG_<0uX=z1Rwx` zyDA_q@}Hgmi);KdcXdCpUl4!*1Rwwb2tWV=5P$##AOL~;EFiA`PvuUe+@IV@?&p1$ zz`jEO0uX=z1Rwwb2tWV=5P$##Zj->0GJd;HwwNd=k^69zwS=mKcUa)}|F>yu(N_pS z00Izz00bZa0SG_<0uX?}l?23p`Qf+!S0Y4Z2tWV=5P$##AOHafKmY;|fWXZa!1e!| zJ2vPU1Rwwb2tWV=5P$##AOHafK;XIrBLDxFx~?|S4g??o0SG_<0uX=z1Rwwb2tWV= HH%s6z*-7VS literal 0 HcmV?d00001 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 @@ - + +