first try for a database for pending registrations
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
$db_file = "db_file.sqlite";
|
$db_file = dirname(__DIR__)."/db_file.sqlite";
|
||||||
|
|
||||||
// create database file when not existent yet
|
// create database file when not existent yet
|
||||||
if (!file_exists($db_file)) {
|
if (!file_exists($db_file)) {
|
||||||
$db = new PDO('sqlite:' . $db_file);
|
$db = new PDO('sqlite:' . $db_file);
|
||||||
|
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
$db->exec("CREATE TABLE registrations(
|
$db->exec("CREATE TABLE registrations(
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
first_name TEXT,
|
first_name TEXT,
|
||||||
@@ -17,13 +18,11 @@ if (!file_exists($db_file)) {
|
|||||||
else {
|
else {
|
||||||
// establish connection
|
// establish connection
|
||||||
$db = new PDO('sqlite:' . $db_file);
|
$db = new PDO('sqlite:' . $db_file);
|
||||||
$ins_stmt = $db->prepare("INSERT INTO registrations
|
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
(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
|
// set writeable when not set already
|
||||||
if (!is_writable($db_file)) {
|
if (!is_writable($db_file)) {
|
||||||
chmod($db_file, 0777);
|
chmod($db_file, 0777);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -44,14 +44,17 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|||||||
$message = $language["SIRNAME_INVALID_FORMAT"];
|
$message = $language["SIRNAME_INVALID_FORMAT"];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// check valid password
|
// check valid password
|
||||||
require_once("../database.php");
|
require_once("../database.php");
|
||||||
$ins_stmt->bindParam(':first_name', $first);
|
$ins_stmt = $db->prepare("INSERT INTO registrations
|
||||||
$ins_stmt->bindParam(':last_name', $last);
|
(first_name, last_name, note, email, username, verify_token)
|
||||||
$ins_stmt->bindParam(':username', $user);
|
VALUES (:first, :last, :note, :email, :username, :token )");
|
||||||
|
$ins_stmt->bindParam(':first', $first);
|
||||||
|
$ins_stmt->bindParam(':last', $last);
|
||||||
$ins_stmt->bindParam(':note', $note);
|
$ins_stmt->bindParam(':note', $note);
|
||||||
$ins_stmt->bindParam(':email', $email);
|
$ins_stmt->bindParam(':email', $email);
|
||||||
$ins_stmt->bindParam(':verify_token ', $vToken);
|
$ins_stmt->bindParam(':username', $user);
|
||||||
|
$ins_stmt->bindParam(':token ', $vToken);
|
||||||
|
|
||||||
$first = filter_var($_POST["first_name"], FILTER_SANITIZE_STRING);
|
$first = filter_var($_POST["first_name"], FILTER_SANITIZE_STRING);
|
||||||
$last = filter_var($_POST["last_name"], FILTER_SANITIZE_STRING);
|
$last = filter_var($_POST["last_name"], FILTER_SANITIZE_STRING);
|
||||||
|
|||||||
Reference in New Issue
Block a user