first try for a database for pending registrations

This commit is contained in:
2018-02-20 20:37:15 +01:00
parent c62bd21646
commit 8fff520b28
2 changed files with 12 additions and 10 deletions

View File

@@ -1,9 +1,10 @@
<?php
$db_file = "db_file.sqlite";
$db_file = dirname(__DIR__)."/db_file.sqlite";
// create database file when not existent yet
if (!file_exists($db_file)) {
$db = new PDO('sqlite:' . $db_file);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->exec("CREATE TABLE registrations(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name TEXT,
@@ -17,13 +18,11 @@ if (!file_exists($db_file)) {
else {
// establish connection
$db = new PDO('sqlite:' . $db_file);
$ins_stmt = $db->prepare("INSERT INTO registrations
(first_name, last_name, note, email, username, verify_token)
VALUES (:first_name, :last_name, :note, :email, :username, :verify_token)");
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
// set writeable when not set already
if (!is_writable($db_file)) {
chmod($db_file, 0777);
}
?>
?>