I think you need to work on thetemplate_include
hook. https://developer.wordpress.org/reference/hooks/template_include
At this point you can add a condition and returning the correct template path
add_filter( 'template_include', 'redirect_single' );
function redirect_single( $template ){
if($_POST['template'] == 'gallery') {
$template = path/to/your/template;
}elseif($_POST['template'] == 'other'){
$template = path/to/your/template;
}
return $template;
}