diff --git a/src/content/docs/en/recipes/build-forms.mdx b/src/content/docs/en/recipes/build-forms.mdx index 408df1244bf39..e5f58523bc1c6 100644 --- a/src/content/docs/en/recipes/build-forms.mdx +++ b/src/content/docs/en/recipes/build-forms.mdx @@ -4,15 +4,16 @@ description: Learn how to build HTML forms and handle submissions in your frontm i18nReady: true type: recipe --- +import { Steps } from '@astrojs/starlight/components'; In SSR mode, Astro pages can both display and handle forms. In this recipe, you'll use a standard HTML form to submit data to the server. Your frontmatter script will handle the data on the server, sending no JavaScript to the client. - ## Prerequisites - A project with [SSR](/en/guides/server-side-rendering/) (`output: 'server'`) enabled ## Recipe + 1. Create or identify a `.astro` page which will contain your form and your handling code. For example, you could add a registration page: ```astro title="src/pages/register.astro" @@ -139,7 +140,7 @@ In SSR mode, Astro pages can both display and handle forms. In this recipe, you' ``` -5. Validate the form data on the server. This should include the same validation done on the client to prevent malicious submissions to your endpoint and to support the rare legacy browser that doesn't have form validation. +6. Validate the form data on the server. This should include the same validation done on the client to prevent malicious submissions to your endpoint and to support the rare legacy browser that doesn't have form validation. It can also include validation that can't be done on the client. For example, this example checks if the email is already in the database. @@ -201,5 +202,4 @@ In SSR mode, Astro pages can both display and handle forms. In this recipe, you' ``` - - +