How to store second dropdown value in database
Your error:


  Notice: Undefined index: city_element_wrapper in
  form_test_custom_form_submit()


means that index city_element_wrapper is missing in $form_state variable. Do this:

function form_test_custom_form_submit($form, &amp;$form_state) {
  $prog_id =1;

  db_insert('tot_prog')
    -&gt;fields(array(
              'state1' =&gt; $form_state['values']['state1'],
              'city_element_wrapper' =&gt; $form_state['values']['city_element_wrapper']['city'],
            ) )
    -&gt;execute();

  drupal_set_message("successfully saved Settings"); 
}


Always take the reference of $form variables if you want to fetch values from the variables or update the values of the variable. For more details about PHP reference read this.