29 lines
768 B
PHP
29 lines
768 B
PHP
<?php
|
|
$db_file = "db_file.sqlite";
|
|
|
|
// create database file when not existent yet
|
|
if (!file_exists($db_file)) {
|
|
$db = new PDO('sqlite:' . $db_file);
|
|
$db->exec("CREATE TABLE registrations(
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
first_name TEXT,
|
|
last_name TEXT,
|
|
username TEXT,
|
|
note TEXT,
|
|
email TEXT,
|
|
verify_token TEXT,
|
|
request_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP)");
|
|
}
|
|
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);
|
|
}
|
|
|
|
// set writeable when not set already
|
|
if (!is_writable($db_file)) {
|
|
chmod($db_file, 0777);
|
|
}
|
|
?>
|