Contact Form Without PHP: How to Build One on a Static Site
Contact Form Without PHP: How to Build One on a Static Site
PHP was the default way to handle contact forms for years. A simple mail() call, a quick validation script, and you were done. But the web has moved on. If you’re building with a static site generator like Astro, Hugo, Jekyll, or Next.js, there’s no PHP runtime available—and adding one defeats the purpose of going static.
You still need a contact form. You just need a different way to handle it.
The Simplest HTML Contact Form
The form itself is just HTML—the same markup you’d use with PHP. The only difference is where the action points:
<form action="YOUR_FORM_ENDPOINT" method="POST">
<div>
<label for="name">Name</label>
<input type="text" id="name" name="name" required />
</div>
<div>
<label for="email">Email</label>
<input type="email" id="email" name="email" required />
</div>
<div>
<label for="message">Message</label>
<textarea id="message" name="message" rows="5" required></textarea>
</div>
<button type="submit">Send Message</button>
</form>
With PHP, the action might point to /contact.php — a script on your server that receives the POST request, parses the fields, and sends an email. Without PHP, it points to a form backend service endpoint — a URL that does all of that for you.
Why Static Sites Need a Form Backend
Static site generators like Astro, Hugo, Jekyll, and 11ty output pre-built HTML, CSS, and JavaScript files. There’s no server executing PHP, no application layer processing requests. Platforms like Netlify, Vercel, and Cloudflare Pages serve flat files and don’t provide a PHP runtime.
This architecture gives you speed, security, and simpler hosting. But your old PHP form workflow — POST request → server-side processing → mail() call — has nothing on the other end to receive it. Whether you’re building a new static site or migrating from WordPress, the same gap exists: you need something to process form submissions, and PHP isn’t available.
The fix isn’t to add PHP back. It’s to point your form’s action to a form backend service — an external endpoint that handles validation, spam filtering, and delivery without a server you maintain.
How Submissions Are Handled Without PHP
When a visitor submits the form, the browser sends an HTTP POST request to the action URL with the form data serialized as key-value pairs. Here’s what happens on the backend side:
- The form backend receives the POST request
- It parses the form fields from the request body
- It validates the data (checking required fields, email format, etc.)
- It filters out spam submissions
- It delivers the data—via email, dashboard storage, webhooks, or all three
This is exactly what a PHP script did. The difference is that a form backend service handles all of this for you, without writing or maintaining any server-side code.
The HTML <form> element works the same way regardless of what’s on the other end. The action attribute is just a URL—it doesn’t care whether that URL points to a PHP script or a form backend service.
Validation Without PHP
PHP forms typically validated input on the server: checking if fields were empty, verifying email formats, rejecting malicious content. You can replicate most of this on the client side using HTML5 constraint validation—no PHP required.
The required attribute, semantic input types, and pattern matching handle the most common cases:
<input type="email" name="email" required />
<input type="text" name="name" required minlength="2" maxlength="100" />
<textarea name="message" required minlength="10"></textarea>
According to MDN’s Constraint Validation guide, these attributes let the browser enforce rules before the form is ever submitted. You can also use the :valid and :invalid CSS pseudo-classes to give users visual feedback:
input:invalid {
border-color: #e53e3e;
}
input:valid {
border-color: #38a169;
}
Client-side validation is a convenience, not security. A form backend adds server-side validation on top—checking required fields, email format, and custom rules after the data arrives. This mirrors what PHP validation did, but without you writing the logic.
Spam Protection Without PHP
PHP forms often included basic spam checks: verifying the referer header, checking for known spam keywords, or requiring a CAPTCHA. A form backend replaces these with built-in protections:
- AI-powered spam detection — Analyzes submission patterns and content to flag suspicious entries automatically
- Honeypot fields — Hidden fields that bots fill out but real humans don’t. When the backend sees data in a honeypot field, it silently discards the submission
- Rate limiting — Blocks repeated submissions from the same IP address within a short time window
- CAPTCHA — Optional challenge verification for high-traffic forms
Adding a honeypot field is a single line of hidden HTML:
<input
type="text"
name="website"
style="display:none"
tabindex="-1"
autocomplete="off"
/>
No PHP required. The form backend handles the filtering on its end. You can name the honeypot field whatever you like — just configure the field name in your backend’s admin panel so it knows which field to check. Use a common name like website or url that bots fill in without raising suspicion.
Delivery Options: What Replaces PHP’s mail()
The biggest thing PHP gave you was mail()—the ability to send an email when someone submitted the form. A form backend provides that and more:
Email Notifications
Same result as PHP’s mail(): you get an email with the submission data. Most form backends let you customize the recipient, subject line, and email template.
Submission Dashboard
Instead of just receiving emails, you can view all submissions in a web dashboard. Search, filter, export to CSV, and manage your data without digging through an inbox.
Webhooks
Forward submission data to other services in real time. Send to Slack, trigger a Zapier workflow, append to a Google Sheet, or push to a custom API endpoint.
Auto-Reply Emails
Send an automatic confirmation to the person who submitted the form. Useful for support tickets, lead capture, or order confirmations—things PHP developers often built custom scripts for.
Using a Form Backend Service Instead of PHP
Here’s the reality: without PHP, you can’t process form submissions from a static HTML page. The server has no runtime to execute your code. You have two options:
-
Write server-side code in a language your host supports. If you’re on traditional hosting (a VPS, a cloud server, or a platform with serverless functions), you can use Node.js, Python, or Go to handle form submissions. This gives you full control, but it means writing, testing, and maintaining backend code.
-
Use a third-party form backend service. If you’re on a static host like Cloudflare Pages, S3, Netlify, or Vercel — or if you simply don’t want to maintain server-side code — a form backend service replaces everything PHP used to do. You point your form’s
actionat their endpoint, and they handle the rest.
The good news is that most form backend services offer free tiers generous enough for personal sites and small projects. FiraForm, Formspree, and Basin all have free plans that cover typical contact form volumes. You don’t need to pay anything to get started.
Here’s how the PHP concepts map to a form backend:
- PHP’s
mail()sent emails when someone submitted the form. A form backend sends email notifications with the same result — you get the submission data in your inbox. - PHP validation scripts checked required fields, email formats, and custom rules on the server. A form backend validates the data after it arrives — same logic, no code to write.
- PHP spam checks (referer headers, CAPTCHA, keyword filtering) protected your inbox. A form backend includes built-in spam filtering — honeypot detection, rate limiting, AI-powered content analysis — that runs automatically.
Most endpoint-based services accept whatever field names your form sends, but field configuration varies by provider. You can change your HTML form anytime, though how the backend handles new fields depends on the service.
The differences between services come down to what they emphasize: some focus on simplicity (just email), others on dashboard management and integrations, and others on being part of a specific hosting platform.
Form Backend Services to Consider
Several services handle form submissions for static sites without PHP. Each takes a slightly different approach, so it’s worth understanding what each one emphasizes:
FiraForm
FiraForm is a headless form backend built for static sites. You point your form’s action to a FiraForm endpoint, and it handles submission processing, spam filtering, email notifications, and webhooks. Fields are auto-detected from the first submission — no dashboard configuration needed. Pricing is among the most generous and affordable in the space, and every plan includes file upload support.
Good for replacing PHP when: You want email notifications, a submission dashboard with CSV export, and webhook integrations without writing backend code. The field auto-detection means you can add, remove, or rename fields in your HTML without touching the backend settings. Built-in CAPTCHA and honeypot spam protection is included on all plans.
Limitations: No built-in payment processing. If you need to accept payments through your form, pair it with a payment service or use serverless functions.
Formspree
Formspree is one of the most widely used form backend services. The setup is minimal: create an endpoint, point your form’s action at it, and submissions arrive in your email inbox. It has a free tier with limited submissions.
Good for replacing PHP when: You just need email delivery from a contact form and nothing else. If your old PHP form was basically “send an email,” Formspree replicates that with almost no overhead.
Limitations: The dashboard is minimal. If you need to search, filter, or manage submissions in a web interface, you’ll want a service with a more robust dashboard.
Netlify Forms
Netlify Forms is built into Netlify’s hosting. If your site is already on Netlify, forms work by adding a netlify attribute to your <form> tag. No external account, no endpoint URL to manage — it’s part of your deployment.
Good for replacing PHP when: Your site is hosted on Netlify and you want the simplest possible setup. Spam filtering is included automatically.
Limitations: Locked to Netlify hosting. If you move your site to another platform, your forms stop working. This is the main trade-off.
Basin
Basin focuses on dashboard management and integrations. Submissions are stored in a web dashboard where you can search, filter, and export data. It supports webhooks for forwarding data to other services.
Good for replacing PHP when: Your old PHP setup included a database or admin panel for managing submissions. Basin’s dashboard gives you that management layer without building it yourself.
Limitations: Smaller ecosystem than Formspree. The free tier has submission limits that may require an upgrade for higher-traffic forms.
Forminit / Getform
Forminit, formerly Getform.io, provides form endpoints with email forwarding and a simple dashboard. It’s a middle ground between Formspree’s email-only approach and Basin’s dashboard-heavy model.
Good for replacing PHP when: You want email forwarding plus a basic dashboard to view submissions. Straightforward and focused on the essentials.
Limitations: Fewer advanced features like webhooks or integrations compared to Basin or FiraForm.
Choosing Between Them
The right choice depends on what you’re replacing and what you need:
| Your old PHP setup did… | Consider |
|---|---|
| Email + a database for submissions + best value | FiraForm |
Just mail() — email only | Formspree, Forminit |
| Email + a database for submissions | Basin |
| Email + CAPTCHA + spam checks | Any of them (all include spam protection) |
| Custom server logic beyond forms | Serverless functions (not a form backend) |
If you’re already on Netlify, start with Netlify Forms — it’s the lowest-friction option. If you’re on a different host, test two or three services against your actual form and see which workflow fits.
PHP vs. Form Backend Services: Quick Comparison
| PHP Form | Form Backend Service | |
|---|---|---|
| Server required | Yes | No |
| Code to maintain | Yes | No |
| Spam protection | Build it yourself | Built in |
| Email delivery | Configure mail() or SMTP | Configured for you |
| Submission storage | Database or files | Dashboard + CSV export |
| Webhooks | Build integrations manually | Built in |
| Hosting flexibility | PHP-capable server only | Any static host |
| Setup time | Hours to days | Minutes |
Conclusion
You don’t need PHP to have a working contact form. The HTML is the same. The validation is the same (or better with HTML5 constraints). The difference is what sits behind the action URL.
A form backend service replaces the PHP script, the mail configuration, the database, and the spam filtering—all in one setup that takes minutes instead of hours. Your static site stays fast and simple. The form just works.
If you’re evaluating options, FiraForm, Formspree, Netlify Forms, and Basin are all worth comparing. The right choice depends on your hosting setup, submission volume, and which integrations matter to you.
Need Forms For Your Static Site?
FiraForm is the headless form backend built specifically for static sites. No backend code needed—just point your forms to our endpoint and we'll handle submissions, validation, notifications, and more.
Free tier available • No credit card required