The Theme has little to do with it.
You can store the referrer in many ways. For example:
add_action('wp', function(){
// conditional logic - if referrer is different to current request URL
// if page ID is 99
if ( wp_get_referer() && is_page(99) ) {
global $my_variable;
$my_variable = wp_get_referer();
}
});
change the 99 to match the page you want to get the referrer on.
And i the referrer URL is different to the current request then it will store it in the global $my_variable
You can then access that variable from your form.