← All learning materials
Database & Forms · 35 MIN READ · DEVELOPER GUIDE

Forms, JSON responses and database records

Learn validation, POST requests, prepared statements and site-scoped storage.

Learning progress is saved in this browser when local storage is available.

The browser submits a request

A form gathers named inputs. JavaScript can submit FormData with fetch, then inspect an HTTP status and JSON response. Validate required fields in the browser for convenience and again on the server for enforcement. Never show success before the server confirms storage.

How project forms are bound

includes/post-template-forms.php attaches published site context and appropriate runtime scripts. process_custom_form.php accepts POST, validates database/table configuration and verifies a real published site or owner before storing site-scoped records. Photography and Real Estate have dedicated enquiry endpoints; their behavior is not interchangeable with generic forms.

SQL syntax and ownership

SELECT reads records, INSERT creates them and UPDATE changes them. PDO prepare plus execute binds values without interpolating raw user input. Placeholders protect values, not table names; identifiers need strict validation. Check CSRF/session rules for each endpoint and include ownership conditions whenever accessing private site data.

Syntax in practice

A focused learning example. Read the referenced source file for its full application context.

$statement = $pdo->prepare('SELECT id FROM sites WHERE id = ? AND user_id = ?');
$statement->execute([$siteId, $userId]);
$allowedSite = $statement->fetchColumn();
// Values are bound; table and column names are fixed in this example.
PUT IT INTO PRACTICE

Try it yourself

On a development site, submit one test enquiry, verify server confirmation and locate its stored record.

Work on a development copy, then explain what changed and how you verified it.

Project file map

Find these paths in your local WebsHigher checkout. Source paths are references, not public downloads of application code.

  • process_custom_form.php
  • includes/post-template-forms.php
  • real-estate-enquiry-api.php
  • photographer-template-api.php

Keep learning

Start here: the WebsHigher codebase →Run the project locally →PHP syntax and reusable page components →
Get Started