Premier test de sqlite : comparaison d'un input de l'utilisateur avec un champ dans la bdd

master
Mehdi 5 years ago
parent cb2ca40ffc
commit 3d1d186e80

@ -0,0 +1,22 @@
<?php
require_once('SqliteDb.php');
$db = new SqliteDb();
$db->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 !';
}

@ -0,0 +1,10 @@
<?php
class SqliteDb extends SQLite3
{
function __construct()
{
$this->open('test.db');
}
}

@ -0,0 +1,24 @@
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
require_once('SqliteDb.php');
$db = new SqliteDb();
$Question1 = $db->querySingle('SELECT question FROM Correct');
?>
<form action="Correcteur.php" method="post">
<p><?php echo $Question1?> <br/> <input type="text" name="R1" /></p>
<p><input type="submit" value="Valider"></p>
</form>
</body>
</html>

@ -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/

@ -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=.

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.php.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/php-project/1">
<name>BddCorrect</name>
</data>
</configuration>
</project>

Binary file not shown.
Loading…
Cancel
Save