-- Create the demo_users_table if it does not exist CREATE TABLE IF NOT EXISTS demo_users_table ( id INTEGER PRIMARY KEY AUTOINCREMENT, first_name TEXT NOT NULL, last_name TEXT NOT NULL, resume TEXT, birth_date DATE, password TEXT NOT NULL, terms BOOLEAN NOT NULL ); -- Include the originally separate sender form, to enter new rows SELECT 'form' AS component, 'New User' AS title, 'Create new user' AS validate; SELECT 'first_name' AS name, 'John' AS placeholder, TRUE AS required; SELECT 'last_name' AS name, TRUE AS required, 'We need your last name for legal purposes.' AS description; SELECT 'resume' AS name, 'textarea' AS type; SELECT 'birth_date' AS name, 'date' AS type, '2010-01-01' AS max, '1994-04-16' AS value; SELECT 'password' AS name, 'password' AS type, '^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$' AS pattern, TRUE AS required, 'Minimum eight characters, at least one letter and one number.' AS description; SELECT 'I accept the terms and conditions' AS label, 'terms' AS name, 'checkbox' AS type, TRUE AS required; -- Insert the submitted form data into the users table only if first_name is not NULL INSERT INTO demo_users_table ( first_name, last_name, resume, birth_date, password, terms ) SELECT :first_name, :last_name, :resume, :birth_date, :password, CASE WHEN :terms IS NOT NULL THEN 1 ELSE 0 END WHERE :first_name IS NOT NULL AND :last_name IS NOT NULL AND :password IS NOT NULL; -- Display a confirmation message SELECT 'text' AS component, CASE WHEN :first_name IS NOT NULL AND :last_name IS NOT NULL AND :password IS NOT NULL THEN 'New user info has been saved!' ELSE 'No data submitted.' END AS contents; -- Display all rows from demo_users_table in a table SELECT 'table' AS component, 'Demo Users' AS title, TRUE AS sort, TRUE AS search; SELECT id AS 'ID', first_name AS 'First Name', last_name AS 'Last Name', resume AS 'Resume', birth_date AS 'Birth Date', -- password AS 'Password', CASE WHEN terms = 1 THEN 'Accepted' ELSE 'Not Accepted' END AS 'Terms Accepted' FROM demo_users_table;