splitforms.com
← Back to the journal

How to Connect an HTML Form to a Database (Without PHP, 2026)

Connect any HTML form to a database without writing PHP or managing a server. Three modern approaches with copy-paste code for 2026.

Start free — 500 submissionsSee pricing →No card, no time limit. Pro is $5/mo.
Short answer
Connecting an HTML form to a database doesn't require PHP or a custom backend. Three modern approaches: use a hosted form backend like splitforms (submissions stored in a searchable dashboard database), write a serverless function that inserts into your own database, or use webhooks to pipe submissions from a hosted backend into PostgreSQL, MySQL, MongoDB, Airtable, or Google Sheets.
Try it on your own form

Point any HTML form at one endpoint. 500 free submissions — no card, no time limit — and unlimited forms.

Create free account

The traditional approach (and why it's hard)

The old way to connect an HTML form to a database looks like this:

HTML Form → PHP script → MySQL INSERT → redirect

This requires:

  • A PHP runtime (or Node.js, Python, Ruby) on your server
  • Database credentials stored on the server
  • SQL injection protection (prepared statements)
  • Connection pooling and error handling
  • Schema design and migrations
  • Backup and retention policy
  • A way to view and export the stored data

That's a lot of infrastructure for a contact form. And if you're on a static host (Vercel, Netlify, GitHub Pages), you don't have a server runtime at all.

Approach 1: Hosted form backend with built-in database

The simplest path. splitforms stores every submission in its own database layer — you get a searchable dashboard, CSV export, API access, and webhook delivery. No database to manage.

<form action="https://splitforms.com/api/submit" method="POST">
  <input type="hidden" name="access_key" value="YOUR_ACCESS_KEY" />
  <input type="hidden" name="subject" value="New submission" />
  <input type="hidden" name="redirect" value="https://yoursite.com/thanks" />

  <input name="name" required />
  <input name="email" type="email" required />
  <input name="company" />
  <select name="plan">
    <option>Starter</option>
    <option>Pro</option>
    <option>Enterprise</option>
  </select>
  <textarea name="message"></textarea>

  <input name="botcheck" type="checkbox" style="display:none" tabindex="-1" />
  <button type="submit">Submit</button>
</form>

Every field in your form is automatically stored. The dashboard lets you search, filter, tag, and export submissions. You also get:

  • Email notifications — each submission arrives in your inbox
  • Spam filtering — rule-based scorer + honeypot, no CAPTCHA needed
  • Webhooks — forward each submission to your own API
  • GDPR basics — encrypted at rest, DPA on every account, delete or export submissions from the dashboard (no automatic expiry)
  • API access — pull submissions via REST API with your API key

Cost: Free for 500 submissions total. Pro at $5/month for 5,000.

Approach 2: Webhook → your own database

You want submissions in your database (PostgreSQL, MySQL, MongoDB). Use splitforms as the front-end receiver, then forward each submission via webhook to your API.

// Your server: POST /api/webhook
import express from 'express';
import { Pool } from 'pg';

const app = express();
app.use(express.json());

const pool = new Pool({ connectionString: process.env.DATABASE_URL });

app.post('/api/webhook', async (req, res) => {
  // Verify the splitforms webhook signature
  const signature = req.headers['x-splitforms-signature'];
  // ... verify HMAC ...

  const { data } = req.body;

  await pool.query(
    'INSERT INTO submissions (name, email, company, plan, message, created_at) VALUES ($1, $2, $3, $4, $5, NOW())',
    [data.name, data.email, data.company, data.plan, data.message]
  );

  res.json({ ok: true });
});

app.listen(3000);

Configure the webhook URL in your splitforms dashboard. Every submission — after spam filtering — is POSTed to your endpoint with an HMAC signature for verification.

This gives you the best of both worlds: splitforms handles form receiving, spam filtering, and email notifications, while your database becomes the system of record.

Approach 3: Serverless function → database

You want to own the entire pipeline. Write a serverless function that receives the form POST and inserts directly into your database.

// Vercel Route Handler: app/api/submit/route.ts
import { Pool } from '@neondatabase/serverless';

const pool = new Pool({ connectionString: process.env.DATABASE_URL });

export async function POST(req: Request) {
  const data = await req.formData();

  // Honeypot check
  if (data.get('botcheck')) return new Response('OK');

  const name = String(data.get('name') ?? '');
  const email = String(data.get('email') ?? '');
  const message = String(data.get('message') ?? '');

  // Insert into PostgreSQL
  await pool.query(
    'INSERT INTO submissions (name, email, message, created_at) VALUES ($1, $2, $3, NOW())',
    [name, email, message]
  );

  return Response.redirect(new URL('/thanks', req.url), 303);
}

Pair this with Neon, Supabase, PlanetScale, or any hosted PostgreSQL/MySQL provider. You own the schema, the data, and the retention policy.

Downside: you're responsible for spam filtering, email notifications, CORS, rate limiting, and error handling. That's why most developers use Approach 1 or 2.

Syncing form data to popular databases

If you're using splitforms with webhooks, here's how to connect to common databases and storage tools:

  • PostgreSQL / MySQL — serverless function inserts rows via webhook
  • MongoDB — insert documents with Mongoose or the native driver
  • Airtable — native one-click OAuth connect, or POST to the Airtable REST API via webhook for custom mapping. See our Airtable integration guide.
  • Google Sheets — native one-click OAuth connect, no Apps Script required. See our Google Sheets guide.
  • Notion — native one-click OAuth connect, or create database items via the Notion API for custom mapping. See our Notion integration guide.
  • HubSpot / Salesforce / Pipedrive — create contacts/deals via CRM API webhooks

Security best practices

  1. Never expose database credentials in client-side code. Always proxy through a server or serverless function.
  2. Use parameterized queries to prevent SQL injection. Never concatenate user input into SQL strings.
  3. Validate and sanitize all input on the server side, not just in the browser.
  4. Rate-limit submissions by IP to prevent flooding.
  5. Encrypt sensitive data before storing. Don't store credit card numbers in form submissions.
  6. Define a retention policy. Delete submissions after a set period to comply with GDPR.

Frequently asked questions

How do I connect an HTML form to a database without PHP?

Use a hosted form backend like splitforms. Point your form's action to https://splitforms.com/api/submit with your access key. Submissions are stored in a searchable database with a dashboard, CSV export, webhook delivery, and email notifications — no server-side code required.

Can I save HTML form data directly to MySQL?

Yes, but you need a server-side layer (Node.js, Python, PHP) between the form and MySQL. Never expose database credentials in client-side HTML. The safest pattern is to use a hosted backend that stores submissions and provides an API for retrieval, or to proxy through a serverless function.

What database does splitforms use to store form submissions?

splitforms operates its own database layer. Every submission is stored with its metadata (timestamp, IP, referring page), searchable in the dashboard, exportable as CSV, and deliverable via signed webhooks to your own database (PostgreSQL, MySQL, MongoDB, Airtable, Google Sheets, etc.).

How do I send form data to Google Sheets instead of a database?

splitforms has a native Google Sheets integration — connect it once from Dashboard → Integrations → Google Sheets and every submission appends as a new row automatically, no webhook or Apps Script required. See our Google Sheets integration guide for step-by-step setup.

Is it safe to store form submissions in a database?

Yes, as long as you follow basic practices: encrypt data at rest, use HTTPS for transmission, implement access controls, and define a data retention policy. splitforms handles the storage side by default — encrypted at rest, submissions kept until you delete or export them from the dashboard (no automatic expiry), so you set and apply your own retention policy.

Start collecting form data today

Your form + a real database. In 90 seconds.
splitforms stores every submission in a searchable dashboard with CSV export, webhooks, and API access. Free for 500 submissions total. No credit card. No server.
Create your free account →

Keep reading

Related articles

More practical guidance from tutorials.

Browse the journal →
Tutorials

FormSubmit File Uploads: How Attachments Work (and Their Limits)

Yes, FormSubmit.co supports file attachments: set enctype="multipart/form-data" and add a fi…

8 min readRead →
Tutorials

React Hook Form + Zod: Schema Validation Step by Step (2026)

Wire Zod into React Hook Form with zodResolver: install, define a schema, infer types, show…

10 min readRead →
Tutorials

React Hook Form reset(): Clear, Reset and Repopulate a Form

How reset() works in React Hook Form: clearing after submit, resetting to new default values…

8 min readRead →

Explore this topic

Start with the overview, then move into focused guides.

OverviewWhat Is a Form Backend? (Complete Guide)Start here →GuideSelf-Hosted vs SaaS Form BackendRead →GuideForm Backend vs Form BuilderRead →GuideWhere Do Form Submissions Go?Read →ReferenceForm backend guideOpen →

Building forms with ChatGPT, Claude, Cursor, or v0? Connect the native MCP server and give your agent a production form backend.

Explore the MCP server →

Give your form a production backend.

One endpoint adds delivery, spam filtering, storage, and integrations. Start with 500 free submissions — no card, no time limit.

Create free accountRead the docs →
Secure checkoutSSL encryptionPrivacyProtected
VISAAMERICANEXPRESSstripe