From 3d1d186e80b91b1e00a0275368be85c89ce2dc4b Mon Sep 17 00:00:00 2001 From: Mehdi Date: Fri, 29 May 2020 22:58:36 +0200 Subject: [PATCH] Premier test de sqlite : comparaison d'un input de l'utilisateur avec un champ dans la bdd --- BddCorrect/Correcteur.php | 22 ++++++++++++++++ BddCorrect/SqliteDb.php | 10 ++++++++ BddCorrect/index.php | 24 ++++++++++++++++++ .../nbproject/private/private.properties | 6 +++++ BddCorrect/nbproject/project.properties | 7 +++++ BddCorrect/nbproject/project.xml | 9 +++++++ BddCorrect/test.db | Bin 0 -> 12288 bytes 7 files changed, 78 insertions(+) create mode 100644 BddCorrect/Correcteur.php create mode 100644 BddCorrect/SqliteDb.php create mode 100644 BddCorrect/index.php create mode 100644 BddCorrect/nbproject/private/private.properties create mode 100644 BddCorrect/nbproject/project.properties create mode 100644 BddCorrect/nbproject/project.xml create mode 100644 BddCorrect/test.db diff --git a/BddCorrect/Correcteur.php b/BddCorrect/Correcteur.php new file mode 100644 index 0000000..5459f58 --- /dev/null +++ b/BddCorrect/Correcteur.php @@ -0,0 +1,22 @@ + + +exec('DROP TABLE Correct'); +$db->exec('CREATE TABLE Correct (question STRING, reponse STRING)'); +$db->exec("INSERT INTO Correct VALUES ('Ceci est la question 1 ', 'réponse 1')"); + +$reponseUser = $_POST['R1']; +$reponseDb = $db->querySingle('SELECT reponse FROM Correct'); + +if ($reponseDb == $reponseUser) { + echo 'Bonne réponse !'; +} else { + echo 'Mauvaise réponse !'; +} + + diff --git a/BddCorrect/SqliteDb.php b/BddCorrect/SqliteDb.php new file mode 100644 index 0000000..5eee981 --- /dev/null +++ b/BddCorrect/SqliteDb.php @@ -0,0 +1,10 @@ +open('test.db'); + } +} + diff --git a/BddCorrect/index.php b/BddCorrect/index.php new file mode 100644 index 0000000..c4c6003 --- /dev/null +++ b/BddCorrect/index.php @@ -0,0 +1,24 @@ + + + + + + + + + querySingle('SELECT question FROM Correct'); + ?> +
+


+

+
+ + diff --git a/BddCorrect/nbproject/private/private.properties b/BddCorrect/nbproject/private/private.properties new file mode 100644 index 0000000..b492277 --- /dev/null +++ b/BddCorrect/nbproject/private/private.properties @@ -0,0 +1,6 @@ +copy.src.files=false +copy.src.on.open=false +copy.src.target=C:\\xampp\\htdocs\\PhpProject1 +index.file=index.php +run.as=LOCAL +url=http://localhost/BddCorrect/ diff --git a/BddCorrect/nbproject/project.properties b/BddCorrect/nbproject/project.properties new file mode 100644 index 0000000..911a7b8 --- /dev/null +++ b/BddCorrect/nbproject/project.properties @@ -0,0 +1,7 @@ +include.path=${php.global.include.path} +php.version=PHP_70 +source.encoding=UTF-8 +src.dir=. +tags.asp=false +tags.short=false +web.root=. diff --git a/BddCorrect/nbproject/project.xml b/BddCorrect/nbproject/project.xml new file mode 100644 index 0000000..9a7e2d5 --- /dev/null +++ b/BddCorrect/nbproject/project.xml @@ -0,0 +1,9 @@ + + + org.netbeans.modules.php.project + + + BddCorrect + + + diff --git a/BddCorrect/test.db b/BddCorrect/test.db new file mode 100644 index 0000000000000000000000000000000000000000..67e9aa1a1e8f09a8392e0448cec21f009b9515d9 GIT binary patch literal 12288 zcmeI&u}Z^09LMpyMBF6V9J>4kK?@=j-RxiuL4+c<%?reGVxTs9IR^(PpT?yx;pQXs zX?oHq#SX!($oIG(x%(#v$!AM)qd~uLM(#@ckUKe1vC>+dizubKKA}(GqkRs1wtT+Z zSFNda)$yt9_^Wg@Q_(DXZCb#21Q0*~0R#|0009ILKmY**{-eNKtEFFDemgNqX{{N% z`Vc0=w3nrl^)C9U)J3_`+q-{SaQO6WDp!&qjt=CPbsrk=M~OvC7NWyTNz z1Q0*~0R#|0009ILKmY**Hc%iAgLZabRN{Ls&cF7@!CFQCt}Oq}&s8+vz(?Yi5I_I{ s1Q0*~0R#|0009ILK%hZjUx#OVi5VB-KLyAnm!GWw9kCzp%UuAS1s``&O8@`> literal 0 HcmV?d00001