title: Correctly format URL link in PHP
body: <p>I have a custom field (called 'website') where a user enters the website to their URL. My php code is as follows</p>
  
  <pre><code>&lt;div class="profileInfo"&gt;
     &lt;h4  class="website"&gt;Website:&lt;/h4&gt;
        &lt;?php if ( get_post_meta($post-&gt;ID, 'website', true)) { ?&gt;
          &lt;p&gt;&lt;a href="http://&lt;?php echo get_post_meta($post-&gt;ID, 'website', true) ?&gt;"&gt;&lt;?php echo get_post_meta($post-&gt;ID, 'website', true) ?&gt;&lt;/a&gt;&lt;/p&gt;
        &lt;?php } else { ?&gt;
      &lt;p class="na"&gt;no email provided&lt;/p&gt;
      &lt;?php } ?&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>In the above example I prefix the URL with http://</p>
  
  <p>So my problem is, when a user enters a url like <a href="http://www.example.com" rel="nofollow">http://www.example.com</a> to the custom field it does not link to the site correctly. The URL looks like this on the frontend http//www.example.com </p>
  
  <p>Strangely the colon : is stripped away or taken out so the URL does not work!I assume this is something to do with having two http://</p>
  
  <p>Now, I have tried removing the http:// from the PHP code liek this </p>
  
  <p><code>&lt;p&gt;&lt;a href="&lt;?php echo get_post_meta($post-&gt;ID, 'website', true) ?&gt;"&gt;&lt;?php echo get_post_meta($post-&gt;ID, 'website', true) ?&gt;&lt;/a&gt;&lt;/p&gt;</code></p>
  
  <p>So let's say the user now enters www.example.com to the custom field and publishes the entry. The Url now goes to </p>
  
  <p><a href="http://mysite.com/www.example.com" rel="nofollow">http://mysite.com/www.example.com</a></p>
  
  <p>It tries to build the URL into my current site page. No idea why it does not treat it as a URL.</p>
  
  <p>Looking for some help how to correctly write this code in PHP.</p>
  
  <p>Thanks </p>