Your First Page - Step 6

Build your first Thorm page and learn the basic workflow: structure, state, and rendering mode.

The API

../api/index.php Calling this an API is a long stretch—very long. It’s really just a stub so the contact form can get a server response and demonstrate how the form works. Since this is part of the tutorial series, I’ve placed it in /tutorials/api to provide a clean URI when used from the website. You can put it anywhere on your server as long as it’s reachable, but you’ll need to update the contact form’s path accordingly.

PHP
<?php declare(strict_types=1); session_start(); header('Content-Type: application/json; charset=utf-8'); $response = new \stdClass(); $response->status = 'error'; $response->message = 'Invalid POST.'; $response->post = $_POST; $fullName = (string)($_POST['fullname'] ?? ''); $email = (string)($_POST['email'] ?? ''); $subject = (string)($_POST['subject'] ?? ''); $message = (string)($_POST['message'] ?? ''); if(!$fullName){ $response->message = 'Invalid name.'; } elseif(!$email){ $response->message = 'Invalid email.'; } elseif(!$message){ $response->message = 'Invalid message'; } else { $response->status = 'success'; $response->message = 'Zing! Your message just launched into our inbox cannon. We will respond before the dust cloud settles.'; } echo json_encode($response);
Status: Developer Preview
Things may change, things might break. If something feels awkward, it's probably a design edge we're still smoothing out.