add function for database and template file of form.