query("CREATE TABLE IF NOT EXISTS 'brain' ('id' integer primary key autoincrement, 'category' varchar(50) NOT NULL default 'default', 'text' text NOT NULL, 'timestamp' timestamp NOT NULL default CURRENT_TIMESTAMP, 'active' tinyint(1) NOT NULL default '1');"); // We need to sanitize the input before we do anything // I'm being a bit lazy here, but that's because I don't really care if anyone hacks my sqlite file, there's nothing secret in it ;) if(isset($_GET['c'])) $_GET['c'] = sqlite_escape_string($_GET['c']); if(isset($_GET['n'])) $_GET['n'] = sqlite_escape_string($_GET['n']); // Adding to db if(isset($_POST['add']) AND !empty($_POST['add'])) { $category = sqlite_escape_string($_GET['c']); $text = sqlite_escape_string($_POST['add']); $dbh->query('INSERT INTO brain (category, text) VALUES (\'' . $category . '\', \'' . $text . '\');'); } // Show the default category if no category has been selected. if(!isset($_GET['c']) OR empty($_GET['c'])) { header("Location: " . $_SERVER['PHP_SELF'] . "?c=default"); } ?>
| query($sql) as $row) { echo "" . $row['0'] . " "; } ?> |