Collecting data from a form and saving to a database
Using
the same two tables of the previous recipe, we will create a form that will allow the user to select a language, add a function name, its summary, and related examples. We will then save this information to the functions
table with the selected language.
Getting ready
Create Recipe2
folder inside the Chapter8
directory.
How to do it...
Create a file named
index.php
inside theRecipe2
folder. Now, create a form with four fields. First, create a select box and query thelanguage
table to fill languages in it. Next, create two textboxes for Function name and Summary. Finally, create a textarea in which users will enter the example for that function. Assign a CSS class namedrequired
to each of these elements.Before the closing of
body
tag, include thejquery.js
file and after that, write the event handler function for the form'ssubmit
event. This function will perform a basic validation by checking each element's value. If any of the...