How to autofill text fields in form? I have two pages, on the first page, the user types in an ID. Using hook_form_alter, I then override the submit function and add my own functionality that will then grab information from a database about the id, such as their name and email. 

It then directs the user to a second page with empty fields asking for name, email etc. My question is, what is the easiest way I auto-fill these fields with the data fetched previously?

thanks!
You should check out https://drupal.stackexchange.com/a/54387/4387 

function MYMODULE_some_form($form, &amp;$form_state) {
  // If the form has been submitted, output something related to the submission
  if (!empty($form_state['values']['some_field'])) {
    // Get data from database and show second step fields.
    $form['user_name'] = array(
      '#type' =&gt; 'textfield',
      // ...
    );

  }
  else {
    // Otherwise build the normal form (first step).
    $form['user_id'] = array(
      '#type' =&gt; 'textfield',
      // ...
    );
  }

  return $form;
}

function MYMODULE_some_form_submit($form, &amp;$form_state) {
  $form_state['rebuild'] = TRUE;
}