Jump to content

Formating link input


sylvain

Recommended Posts

Hi!

 

I'm working a on wordpress website with member pages. Members enter their information via custom fields. Everything is working great except when trying to create a link based on one of those custom field. Unless the member enter his website address in the http://mysite.com format the link my code create is not valid.

 

This is the code i'm currently using

<?php $msite = get_post_meta($post->ID, 'ccio_site', true) ; if (!empty($msite)) { ?><li>Site Internet: <a href="<?php echo ($msite) ; ?>"><?php echo ($msite) ; ?></a></li><?php } ?>

 

Example of a member page where the format create an error. The input field is:

www.pechabot.com

 

 

Example of a member page where the format is ok. The input field is

http://www.annuairesgb.com

 

How can I format the input string so my code will work even if someone doesn't write the full address with the http:?

 

Thanks a lot for looking

Link to comment
https://forums.phpfreaks.com/topic/236253-formating-link-input/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.