diff --git a/config.sample.php b/config.sample.php index e998fdb..72f7162 100644 --- a/config.sample.php +++ b/config.sample.php @@ -1,6 +1,6 @@ diff --git a/database.php b/database.php new file mode 100644 index 0000000..3bd1b81 --- /dev/null +++ b/database.php @@ -0,0 +1,29 @@ +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); +} +?> \ No newline at end of file diff --git a/register.php b/register.php index eb177b4..02ccca9 100644 --- a/register.php +++ b/register.php @@ -41,15 +41,22 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { } else { // check valid password + require_once("../database.php"); + $ins_stmt->bindParam(':first_name', $first); + $ins_stmt->bindParam(':last_name', $last); + $ins_stmt->bindParam(':username', $user); + $ins_stmt->bindParam(':note', $note); + $ins_stmt->bindParam(':email', $email); + $ins_stmt->bindParam(':verify_token ', $vToken); $first = filter_var($_POST["first_name"], FILTER_SANITIZE_STRING); $last = filter_var($_POST["last_name"], FILTER_SANITIZE_STRING); $user = filter_var($_POST["username"], FILTER_SANITIZE_STRING); - $pass = filter_var($_POST["password"], FILTER_SANITIZE_STRING); - $email = filter_var($_POST["email"], FILTER_VALIDATE_EMAIL); $note = filter_var($_POST["note"], FILTER_SANITIZE_STRING); + $email = filter_var($_POST["email"], FILTER_VALIDATE_EMAIL); + $vToken= bin2hex(random_bytes(16)); - + $ins_stmt->execute(); $success = true; } if ($success) { @@ -67,7 +74,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { } else { $_SESSION["token"] = bin2hex(random_bytes(16)); ?> - Registriere dich für cg-s.tk + Registriere dich für <?php echo $homeserver; ?>