Modify a variable before it saves to database
I don't think your approach is the best. You need to do the following: 


Add a custom module.
Implement hook_form_alter in your module and and alter the user
profile form. Form id: user-profile-form.
Add a validation function i. e. $form['#validate'][] =
'my_module_custom_form_validate';.
add an implementation for the function in your module and modify the form values as you wish.


Also, you don't need to use the $_POST variable if you are following the drupal form api.