PHP Forms and Sessions Sandbox

CSC-329 · Semester V · Web Technology

PHP Forms & Sessions

Client submits, server validates, session remembers.

Server-side check will fail: username ≥ 3 chars, valid email, age ≥ 18.

<?php session_start();

if ($_post['username'] ?? '') {

$_SESSION['user'] = htmlspecialchars($_post['username']);

} ?>

Submit the form to see how PHP reads POST data and stores the identity in the session cookie. GET places data in the URL; POST keeps it in the request body.