Widget redirecting to home page

A bit of a guess but if the search works but returns you to the home page it sounds like get_permalink( $post->ID ) is not giving you the right values. Look at the page source to confirm. That implies that $post is not set, or not accessible, so put global $post; in your function before you try to use that variable. I’d suggest something like this right at the top of your function:

global $post;
$pid = (isset($post->ID)) ? get_permalink($post->ID) : '';

Then use $pid instead of $post->ID after that.

To the extent that I can test that widget (It calls a class I don’t have and the URL to the actual domain search is only partial.) it is operating mostly as expected. This…

  $p = get_queried_object();
  $pid = (isset($p->ID)) ? get_permalink($p->ID) : home_url();

… will get you a little bit better results than the previous block but you are actually redirecting to $referer$referrer = $_SERVER['HTTP_REFERER'];— not to that permalink anyway. In context, it is a bit confusing what you are trying to do at all.

I don’t understand the way you have the widget “registered”. I got an error until I altered the last few lines to :

function register_HND_widget() {
  register_widget('HNDomainSearchWidget');
}

add_action('widgets_init', 'register_HND_widget');

Also, you should really have debugging enabled. That code generates a fair number of Notices.