How to go to external website from within a module? I have created a custom module in which when a user enters a valid id, it should them take them to an external website. The problem I am having is redirecting to the external website. The code I am using in my module is to do the redirection is:

  // clear out the output buffer
  ob_start();
  while (ob_get_status()) {
    ob_end_clean();
  }
  return header("Location: $external_url");


This doesn't work. What should I be using to accomplish this? 

Thanks.
You should use drupal_goto to redirect to a URL.

drupal_goto($external_url, array('referral' =&gt; $referral_url));