diff --git a/examples/official-site/sqlpage/migrations/01_documentation.sql b/examples/official-site/sqlpage/migrations/01_documentation.sql index c9eda2b74..39b6d64ea 100644 --- a/examples/official-site/sqlpage/migrations/01_documentation.sql +++ b/examples/official-site/sqlpage/migrations/01_documentation.sql @@ -267,8 +267,7 @@ A value in a field named "x" will be available as `:x` in the SQL query of the t INSERT INTO parameter(component, name, description_md, type, top_level, optional) SELECT 'form', * FROM (VALUES -- top level ('enctype', ' -When ``method="post"``, this specifies how the form-data should be encoded -when submitting it to the server. +Encoding used for POST submissions. Use `multipart/form-data` for file uploads. ', 'TEXT', TRUE, TRUE), -- item level ('formenctype', ' @@ -283,7 +282,7 @@ is automatically applied to the default validate button. ); INSERT INTO parameter(component, name, description, type, top_level, optional) SELECT 'form', * FROM (VALUES -- top level - ('method', 'Set this to ''GET'' to pass the form contents directly as URL parameters. If the user enters a value v in a field named x, submitting the form will load target.sql?x=v. If target.sql contains SELECT $x, it will display the value v.', 'TEXT', TRUE, TRUE), + ('method', 'The default is `POST`: read a field named `x` as `:x` on the target page. Use `GET` for bookmarkable searches and filters; the field appears in the URL as `?x=value` and can be read as `$x`.', 'TEXT', TRUE, TRUE), ('action', 'An optional link to a target page that will handle the results of the form. By default the target page is the current page with the id of the form (if passed) used as hash - this will bring us back to the location of the form after submission. Setting it to the name of a different sql file will load that file when the user submits the form.', 'TEXT', TRUE, TRUE), ('title', 'A name to display at the top of the form. It will be displayed in a larger font size at the top of the form.', 'TEXT', TRUE, TRUE), ('validate', 'The text to display in the button at the bottom of the form that submits the values. Omit this property to let the browser display the default form validation text, or set it to the empty string to remove the button completely.', 'TEXT', TRUE, TRUE), @@ -567,16 +566,16 @@ But note that SQLPage cookies already have the `SameSite=strict` attribute by de You can use the `file` type to allow the user to upload a file. The file will be uploaded to the server, and you will be able to access it using the -[`sqlpage.uploaded_file_path`](functions.sql?function=uploaded_file_path#function) function. +[`sqlpage.uploaded_file_path`](functions.sql?function=uploaded_file_path) function. Here is how you could save the uploaded file to a table in the database: ```sql INSERT INTO uploaded_file(name, data) VALUES ( - :filename, + sqlpage.uploaded_file_name(''my_file''), sqlpage.read_file_as_data_url(sqlpage.uploaded_file_path(''my_file'')) -) +); ``` ', json('[{"component":"form", "enctype": "multipart/form-data", "title": "Upload a picture", "validate": "Upload", "action": "examples/handle_picture_upload.sql"}, @@ -645,7 +644,7 @@ to specify the format of the CSV file, but makes it work with all supported data Here is how you could easily copy data from a CSV to a table in the database: ```sql -copy product(name, description) from ''product_data_input'' +copy product(name, description, price) from ''product_data_input'' with (header true, delimiter '','', quote ''"''); ``` @@ -658,7 +657,7 @@ create temporary table if not exists product_tmp(name text, description text, pr delete from product_tmp; -- copy the data from the CSV file into the temporary table -copy product_tmp(name, description, price) from ''product_data_input''; +copy product_tmp(name, description, price) from ''product_data_input'' with (header true); -- insert the data into the final table, converting the price column to an integer insert into product(name, description, price) diff --git a/examples/official-site/sqlpage/migrations/07_authentication.sql b/examples/official-site/sqlpage/migrations/07_authentication.sql index ca44e9c48..766428763 100644 --- a/examples/official-site/sqlpage/migrations/07_authentication.sql +++ b/examples/official-site/sqlpage/migrations/07_authentication.sql @@ -131,7 +131,7 @@ You can check if the user has sent the correct password in a form, and if not, r Create a login form in a file called `login.sql` that uses the [login component](?component=login): ```sql -select ''login'' as component; +select ''login'' as component, ''create_session_token.sql'' as action; ``` And then, in `create_session_token.sql` : @@ -146,13 +146,6 @@ SELECT ''authentication'' AS component, ``` -and in `login.sql` : - -```sql -SELECT ''form'' AS component, ''Login'' AS title, ''my_protected_page.sql'' AS action; -SELECT ''password'' AS type, ''password'' AS name, ''Password'' AS label; -``` - ### Advanced: usage with a session token Calling the `authentication` component is expensive. diff --git a/examples/official-site/sqlpage/migrations/43_request_method.sql b/examples/official-site/sqlpage/migrations/43_request_method.sql index e5868b6d8..b4beb545d 100644 --- a/examples/official-site/sqlpage/migrations/43_request_method.sql +++ b/examples/official-site/sqlpage/migrations/43_request_method.sql @@ -16,7 +16,7 @@ VALUES HTTP request methods (also known as verbs) are used to indicate the desired action to be performed on the identified resource. The most common methods are: - **GET**: retrieve information from the server. This is the default method used by browsers when you click on a link. - - **POST**: submit data to be processed by the server. This is the default method used by browsers when you submit a form. + - **POST**: submit data to be processed by the server. SQLPage''s [form component](/component.sql?component=form) defaults to POST; a plain HTML form defaults to GET. - **PUT**: replace the current representation of the target resource with the request payload. Most commonly used in REST APIs. - **DELETE**: remove the target resource. - **PATCH**, **HEAD**, **OPTIONS**, **CONNECT**, **TRACE**: less common methods that are used in specific situations.