Whether it’s a log-in screen, online questionnaire or contact page, forms are a very common occurrence on the worldwide web.
This week we’ll have a look at coding a simple form, submitting it, performing some basic input validation, and saving the data entered into a database.
To make the excercise useful, the plan is to cover both the front-end and back-end aspects of this topic. By back-end we mean the part where we actually send the input data out to the server, and save that data in the database.
In order to be able to follow along and get the most out of this session, you may want to install something like WampServer on your laptop ahead of the session. This gives you the server and database pieces of the puzzle.
Alternatively, and probably much easier, you may want to sign up free onto Cloud9 as suggested in this blog post from some weeks ago. More details as to what Cloud9 is (and is not) can be found here and officially here.
This is the complete code example. Please post any questions or difficulties in the comments section below.
###index.html
###script.js
###style.css
And here is the back-end SQL code for creating the database table, and the PHP code for saving the form data to that table: