An on line form can make processes such as college applications very efficient and will ensure that important pieces of information are stored in a database
As a web application developer it is always surprising the number of times that the same piece of information needs to recorded in some organizations. Take, for example, a typical college web site
- a potential student finds the course that they wish to study;
- they download an editable PDF file and fill in the required details;
- they then email the PDF file to a member of staff at the college;
- the member of staff prints off the form;
- finally they update an Excel spreadsheet with the information.
There is an even worse scenario: a potential student finds the course that they wish to study; they phone a contact number at the college; the staff member writes the student's details on a post-it note; the staff member then takes another call; the post-it note travels off to another desk stuck to the bottom of a coffee cup.
Obviously neither scenario is a good one but both happen. And, of course, both scenarios are completely avoidable. All that's needed is an on-line form that saves the information into a database. That may sound difficult but can be achieved very simply and very quickly.
The Process of Updating a Database from a Web Page
There are three elements that are need in order to create an on-line data entry application:
- a database: typically this will be a standard database such as MySQL;
- the data entry form: this is some simple HTML on a web page;
- a PHP file on a web server: this processes the data received from form so that it can be loaded into the database by running a SQL statement
Now, that may sound very straightforward, and it is.
An HTML Form
An HTML form is a simple piece of text within any web page. It consists of:
- the opening form tag which has two key properies:
- the action – this is the url of the PHP file to be called once the form is completed;
- the method – this can either be get (the form data is passed as part of the url) or post (the data is - passed as a standard input and is not directly visible to the user) - input tags: these allow the user to interact the form and each one can be a different type, for example: text; password; checkbox; radio. Each input requires a unique identification stored in its name property;
- a special input of type submit – this appears as a button and submits the data to the PHP file for processing;
- a closing form tag after all of the input fields.
So, the form is used to gather the required information. This is then sent to the PHP file so that it can be formatted ready for sending to the MySQL database;
PHP Data Processing
The PHP file receives the submitted data as an array called $_REQUEST. So, for example, if one of the input fields in the form has the name "firstname" then this will be passed as $_REQUEST['firstname']. This array can then be used to create a suitable insert, update or delete SQL statement:
$sql = "insert into college_application (firstname,surname)
values '{$_REQUEST['firstname']}', '{$_REQUEST['surname']}'";
And then run on the database:
mysql_query($sql);
Therefore, with a few simple lines of code, any data only needs to be entered once and will not be lost on anyone's desk.
Posted on Utopian.io - Rewarding Open Source Contributors
Your contribution cannot be approved yet because it is not as informative as other contributions. You have mostly just listed the options and filled them with your personal data but you have not explained them in detail. See the Utopian Rules. Please edit your contribution and add try to improve the length and detail of your contribution, to reapply for approval.
You may edit your post here, as shown below:
You can contact us on [Discord].
[utopian-moderator]
Done
The contribution must contain as much detail as possible and have some graphical content in it (images, charts, videos, etc) where applicable. Please edit your contribution and add try to improve the length and detail of your contribution, to reapply for approvalhi @alv ..
You can contact us on Discord.
[utopian-moderator]
Your contribution cannot be approved because it is not as informative as other contributions. See the Utopian Rules. Contributions need to be informative and descriptive in order to help readers and developers understand them.
You can contact us on Discord.
[utopian-moderator]