I have a form (admin form) that asks for credentials to connect to a second database. If you input the information in the form and save and then create a new user it works. If you re-visit the admin form and have a typo on the password it still saves the information, but now when you log out and create a new user it takes site offline, I assume it would do same thing if the database or username is incorrect as well. This brings up 2 problems that I can think of:
1. verify the database, username, password and host are correct.
2. have some way yo change the password.

$form['dbsettings']['dbname'] = array(
        '#type' => 'textfield',
        '#title' => t('Database name'),
        '#description' => t('The database name that the FreeRadius will use. This database needs to already be created and set up by someone with permissions to do so.'),
        '#required' => TRUE,
        '#default_value' => variable_get('dbname',''), 
        '#size' => 25,
    );
    $form['dbsettings']['dbuser'] = array(
        '#type' => 'textfield',
        '#title' => t('Database username'),
        '#description' => t('The database username that is required to connect to the FreeRadius database.'),
        '#required' => TRUE,
         '#default_value' => variable_get('dbuser',''),
        '#size' => 16,
    );
    $form['dbsettings']['dbpass'] = array(
        '#type' => 'password',
        '#title' => t('Database password'),
        '#description' => t('The database password that is required to connect to the FreeRadius database.'),
        '#required' => TRUE,
        '#default_value' => variable_get('dbpass',''),
        '#size' => 16,
    );
    $form['dbsettings']['dbhost'] = array(
        '#type' => 'textfield',
        '#title' => t('Database host'),
        '#description' => t('The database hostname that is required to connect to the FreeRadius database. The hostname localhost will be assumed if left blank.'),
        '#default_value' => variable_get('dbhost','localhost'),
        '#size' => 50,
    );

function freeradius_dbsettings_form_validate(&$form, &$form_state) {
    global $user;
    // Set up variables for the values of are fields
    variable_set('dbname', 'dbname');
    variable_set('dbuser', 'dbuser');
    variable_set('dbpass', 'dbpass');
    variable_set('dbhost', 'dbhost');
    variable_set('enctype', 'enctype');
    variable_set('defaultop', 'defaultop');
    variable_set('usergroup', 'usergroup');
    
    if ($form['settings']['usergroup']['#options'][0] == 'Please create Role') {
        form_set_error('usergroup', 'Please visit the <a href="/admin/user/roles">Roles</a> page and add at least one role other then "anonymous user ,authenticated user or administrator".');
    }
    
    // If the value for dbname is empty give a error showwing it required
    if (is_null($form_state['values']['dbname'])) {
        form_set_error('dbname', t('The database name is a REQUIRED field.'));
    }

    // If the value for dbuser is empty give an error showing it is required
    if (is_null($form_state['values']['dbuser'])) {
        form_set_error('dbuser', t('The database username is a REQUIRED field.'));
    }
    
    // If the value of dbpass is empty give an error showing it is required
    if (is_null($form_state['values']['dbpass'])) {
        form_set_error('dbpass', t('The database password is a REQUIRED field.'));
    }
    // If the value of dbhost is not empty and it is numeric give an error saying it shouldn't be numeric
    if (!is_null($form_state['values']['dbhost']) && is_numeric($form_state['values']['dbhost'])) {
        form_set_error('dbhost', t('The value entered here should not be numeric.'));
    }
    
    // If the value of dbhost is left blank set it to localhost
    else {
        $form_state['values']['dbhost'] = 'localhost';
    }
}