PHP: Self-Processing Pages

Derek Bridge

Department of Computer Science,
University College Cork

PHP: Self-Processing Pages

Aims:

Big head

Self-processing page

Self-processing page

[Diagram that shows a self-processing being requested and data being submitted]

Pseudocode

    
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;
}

A useful function

Another useful function

Class exercises

  1. Write the rest of the head_to_hat.php script
  2. If you wanted to validate the user's data, what changes would you make?

A small modification