Wrong url


I have made an addon by myself wich almost works well

When i place on my product page an url which has to point to an external website i got a problem:

I places this code in my scripts:

Where $external_url must show the url
www.test.nl which point to the external website.

But when i click on the url in the front of my site i get an error page because my website url is also placed in front of the external url like this:


Does anybody know how i can solve this?