Module Development

Movie Project: Add Form Data to Custom Database Tables for Drupal 7

This page is archived

We're keeping this page up as a courtesy to folks who may need to refer to old instructions. We don't plan to update this page.

Add user data to the database from an existing form.


Save data from a form to a custom database table.


You will need the following knowledge and skills. If you need a review, check out the Additional resources section at the bottom of this page.

  1. Understand how to update user information in the database.
  2. Use database queries.
  3. Use default values in forms.


Create a function to save the user data which has been submitted in the altered user form.

Create a function to put the data into the new table created earlier.

Create functions to retrieve the data from the form.

Set the default values of the new fields.


  • hook_user_update can be used to manage additional functionality for a user object.
  • Break down functions to set and retrieve data, so they can be re-used.

Further your understanding

Additional resources

Creative Commons License

Drupal Training Resources by Damian Robinson are licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. Based on a work at

Hands-On Exercises: Movie Project