Aims:
head.html
: an HTML web page that contains a form
<form action="hat.php" method="get"> <input type="text" name="circumference" /> <input type="submit" /> </form>
hat.php
: a PHP script that receives the data, carries out
the calculation, and echoes the result into a new web page
head_to_hat.php
if the user is requesting the form for the first time { output a web page containing the form; } else // i.e. s/he has requested it previously, has filled it in, // has pressed submit, and is sending us data { calculate the person's hat size; output a web page containing the form and the hat size; }
action
attribute
function output_form() { echo "<form action=\"{$_SERVER['PHP_SELF']}\" method=\"get\">"; output_textfield('circumference', 'Circumference: ', 'circumference', 4, 4, '', false); output_submit_button('Submit'); echo "</form>"; }
function is_initial_request() { return ! isset($_GET['submit']); }
head_to_hat.php
script