- Add Form to HTML
<form netlify name="guestbook" method="POST">
<label>
Jouw naam:
<input name="name" type="text" required="required" minlength="2" />
</label>
<label>
Bericht:
<textarea name="message" required="required" minlength="5"></textarea>
</label>
<button>Verzenden</button>
</form>
- Add guestbook output div to html
<div id="guestbookOutput"></div>
- Add luxon and custom guestbook.js script tags to html
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/build/global/luxon.min.js"
integrity="sha256-e2xkOE+oa0Ux7mVa39RFbhewJ4rMMlud92zYs61NHFY="
crossorigin="anonymous"
></script>
<script src="guestbook.js"></script>
- store
guestbook.js
next to html file
- store
submissions.js
in a folder called netlify/functions/
in the root of your project
- store
package.json
in root of your project
- create a personal access token on Netlify N.B. this access token gives full control on the Netlify api, handle with care.
- store this personal access token in an environment variable on Netlify (Site Settings -> Build & deploy -> Environment) called
NETLIFY_PAT
- publish your netlify site
- do a single form submission to find out the form id (it's in the url when viewing the form on Netlify)
- add an environment variable called
FORM_ID
and give it the value of the formId from the previous step
- trigger a new deploy of your Netlify site
- style the form and messages using css