website design pattern

The most often occurred use case is:

  1. user opens a webpage;
  2. the webpage reads data from database and displays it to the user;
  3. the user modifies some of the data and clicks the submit button;
  4. the webpage collects the data user inputs and saves it to database;

Note that although the action in the front-end form can point to any url to handle the data user inputs, most time, the same webpage as displays the form is used to handle the data transferred back to the server. So the webpage should differentiate the two situations: should it display the form, or should it handle the data user inputs? This can be done using the following design pattern:

if(!$_POST["submit"])
{
    output the form;
}
else
{
   handle the data user inputs;
}

where “submit” is the name of the submit button on the form.

Posted in

Comments are closed, but trackbacks and pingbacks are open.