register_setting allows you to use the WP backend to do these useful tasks:
database updates, some validation and sanitisation, and handling the _nonce_ fields for security.
EDIT2: Whereas I add settings_fields('postie-settings') into the main options form, to generate the _nonce_fields for security.
I did have some difficulty the first time I tried to get register_setting to work, and had to try a few different combinations.
The key is that (as you can see in my patch) you need to run the register_setting call from a function that is hooked into admin_init. So, in the main body of postie.php I add:
if (is_admin()) {
add_action('admin_init','postie_admin_settings');
}
and in postie-functions.php, I add:
function postie_admin_settings() {
register_setting('postie-settings','postie-settings','postie_validate_settings');
}
where the last argument is a validation function.
Then all of the handling of $_POST variables can be removed from the options form, and options can be submitted/retrieved just using get_option('postie-settings') and update_option('postie_settings,$options);
NB that in all three cases, register_setting, get_option and update_option, it's singular not plural (e.g. 'option' not 'options') - that catches me out every time!
But in the case of settings_fields, it's plural "settings" (and "fields"), not singular "setting"!
Regards,
Andrew