Static site contact form on your own server
Put a contact form on a plain HTML site. The form posts to a Formlander server that you host, and the server stores each submission.
A static HTML page can show a contact form, but it has no code that receives the submission. Formlander is a form backend that you run on your own server. Your form posts to it.
What you need
Section titled “What you need”- A Formlander server. The deployment page has the install command.
- A form in its dashboard. Set the address of the form to
contact, and put the domain of your site in Allowed sites. - The Endpoint of the form. Copy it from the page of the form in the dashboard. It contains the token of the form, which is public.
The form
Section titled “The form”Paste this into the page where you want the form:
<form action="https://forms.example.com/forms/contact/submit?token=YOUR_TOKEN" method="post"> <input type="hidden" name="_success_url" value="https://example.com/thanks.html"> <input type="text" name="__fl_hp" value="" tabindex="-1" autocomplete="off" aria-hidden="true" style="position:absolute;left:-9999px">
<label for="name">Name</label> <input type="text" id="name" name="name" autocomplete="name" required>
<label for="email">Email</label> <input type="email" id="email" name="email" autocomplete="email" required>
<label for="message">Message</label> <textarea id="message" name="message" rows="5" required></textarea>
<button type="submit">Send</button></form>Replace the action value with your Endpoint. Change the _success_url value to a page on your site.
You can change the fields. There is no form schema, and Formlander stores the fields it gets as JSON.
Where it goes
Section titled “Where it goes”Put the form inside the <body> of a page, for example contact.html. Make a thanks.html next to it. Upload both files the way you upload the rest of the site. The form needs no JavaScript and no build step.
To test on your computer, add localhost to Allowed sites and serve the folder with a local web server. A local test also ends on the _success_url page, so publish the thank-you page first. If you open the file from disk, the browser does not say which site the form is on, and Formlander answers 403.
What happens on submit
Section titled “What happens on submit”- The browser posts the fields to your Formlander server.
- Formlander checks the token and Allowed sites.
- It stores the submission in its SQLite file. It does not store
_success_urlor__fl_hp. - The browser goes to the
_success_urlpage. Without that field, the visitor sees a short thank-you page on your Formlander domain.
Use a full URL in _success_url, on a site that is in Allowed sites. A path such as /thanks.html opens on the domain of your Formlander server.
The dashboard shows each submission. Formlander can also send each one by email (SMTP or Mailgun) or to a webhook, with retries.
Stay on the page
Section titled “Stay on the page”The optional JavaScript SDK submits the form and shows the result inside it. Remove the _success_url input and add this script to the page:
<script src="https://forms.example.com/assets/formlander.js"></script>The SDK also tries again when the network fails or the server is busy. See Form integration.
Spam settings
Section titled “Spam settings”Allowed sites and the rate limit are always on. The __fl_hp input is a honeypot. People do not see it, and bots fill it. Formlander stores a submission with a filled honeypot as spam and does not send it by email or to a webhook.
If bots still get through, add Cloudflare Turnstile. Spam and security has the steps.
Related pages
Section titled “Related pages”- Form integration covers
fetch, file uploads, and the response format. - Deployment covers the install, backups, and settings.
- Astro contact form and Hugo contact form show the same form in those generators.