<?php
require_once 'config.php';
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
header('HTTP/1.1 400 Bad Request');
"<h1>I only respond to POST requests. This is a "
. $_SERVER['REQUEST_METHOD'] . " request.</h1>";
exit;
}
if (empty($_POST['favorite_color'])) {
header('HTTP/1.1 400 Bad Request');
print '<h1>You must post a <strong>favorite_color</strong>.</h1>';
exit;
}
print '<h1>I am a service that responds to POST requests.</h1>';
require 'script_info.php';
'<h1>Your favorite color is ' . htmlentities($_POST['favorite_color'])
. '</h1>';
if (!isset($_SESSION['n'])) {
$_SESSION['n'] = 0;
}
echo '<p>request #' . (++$_SESSION['n']) . '</p>';