Table of Contents

Note

The PHP script should be placed on a web-server with PDO-SQLite support, next to an sqlite v3 database called questions.sqlite. The sqlite database sets the questions and avatar names as primary keys in order to allow the same questions to be answered several times.

Database Structure

The database structure can be created with the following commands:

questions.sqlite
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE "responses" (
	 "q" text NOT NULL,
	 "v" text NOT NULL,
	 "a" text NOT NULL,
	PRIMARY KEY("v","q")
);
COMMIT;

PHP Script

radio.php
<?php
 
if(!isset($_GET['q']) || !isset($_GET['v']) || !isset($_GET['a'])) return;
 
$qq = $_GET['q'];
$qv = $_GET['v'];
$qa = $_GET['a'];
 
$db = new PDO('sqlite:questions.sqlite');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$query = $db->prepare("REPLACE INTO responses(q,v,a) VALUES(:qq, :qv, :qa)");
try {
 $query->execute(array(':qq' => $qq, ':qv' => $qv, ':qa' => $qa));
}
catch(PDOException $e) {
 die($e->getMessage());
}
print "OK";
 
?>