Once a form is submitted, the server generally takes some action with the processed form. It then returns a standard HTTP response (i.e. a page) to the user which indicates the results of their request in some way.
Basic form handling
When a form is received by the server, it is handled in some way. The web server's configuration determines what initial action is taken based on the URL; normally, this would involve passing the form's contents to a separate program written in an appropriate programming language.
For example, if a server receives a GET request for /search.cgi?keywords=apple, then it might be configured to handle that request by running the separate program stored in its software folder and named 'search.cgi', passing the form contents (keywords=apple) to the program. The server would then accept the output from the search.cgi program, and send it back to the requesting client as an HTTP response.
Similarly, if a server receives a GET request for /customerinfo.asp?id=3345, then it might be configured to handle that request by launching an ASP interpreter and interpreting the template customerinfo.asp. The template contains HTML to be output, interspersed with programming code which generates additional parts of the HTML, probably by accessing a database to find information about customer 3345.
Database software manages large quantities of information in a structured format. From within other software, you can update the database and query it for information.
For example, you might have an order database. When somebody places an order on your online site, the program which handles the form communicates with your database to create a database record for that order, containing the key details (user's details, product ordered, etc.)
It isn't always necessary to use a database when responding to form input (for example, if you have a response form where people can give comments on the site, the software might simply email their comments to a particular address; there would be no need to store the comments in a database). However, databases are often useful.
There are various database technologies, from free (MySQL), through moderately-priced (Microsoft Access), up to higher-priced solutions like Oracle and Microsoft SQL Server. All of these will work fine for a small site (although Access really isn't a good idea for medium or large sites). If you purchase Web hosting rather than hosting your own server, you will need to pay attention to the database that is included by your hosting company.