That first loop of cahva's can be reduced to a single statement:
$_POST = array_map('secure', $_POST);
But quite a few of those mysql_real_escape() calls are pointless. E.g.,
$pay_for_insurance = mysql_real_escape_string($_POST['group1'] == 'pay_for_insurance' ? 1 : 0);
$pay_for_insurance is only ever going to be either 1 or 0, and that doesn't need escaping.
function secure($string) {
$string = strip_tags($string);
$string = htmlspecialchars($string);
$string = trim($string);
$string = stripslashes($string);
$string = mysql_real_escape_string($string);
return $string;
}
You should only need stripslashes() if you're using the deprecated magic quotes feature, and if you're not using that feature you should need stripslashes(). As for htmlspecialchars(), it's better to not use that until you want to display the string as HTML.
And finally, if you're sanitising data so that it can be embedded in a SQL query, the [man]PDO[/man] interface does that automatically (and correctly) with whatever you pass into it.