Insert into table from Drupal 7 I am very new to Drupal.


I have a table called test with two fields: (int) id and (varchar) text
When a new user signs up I want to store data on the table test


I'd like to know how can I do that. I really don't know how to start researching about this. 

I think the most approximately that I have found is Overriding user login. I presume that it does what I want but in the pre-process functions I have to insert into the database. Question here how do I insert into the database from Drupal?

Could anyone clear my thoughts or point me to any good reference. 

Thanks.
You don't need to actually override the login process to do this; The user module provides a hook (hook_user_insert()) which gets invoked any time a new user is created.

As far as inserting into the database goes, the best place to look first is the Database abstraction layer documentation which goes into detail about the various database methods available.

In this specific case it's the db_insert() function you're looking for. Your code might look something like this:

function MYMODULE_user_insert(&amp;$edit, $account, $category) {
  db_insert('custom_table_name')
    -&gt;fields(array(
      'id' =&gt; $account-&gt;uid,
      'text' =&gt; 'some text'
    ))
    -&gt;execute();
}


This code would go inside a custom module; if you're not familiar with creating one of those check out the Module developer's guide which will tell you everything you need to know.