monkeybidz Posted October 10, 2007 Share Posted October 10, 2007 How can i remove a URL link from a form text field or the area where results are posted when a user enters http://www.mywhateversite.com. For example, here on this site. I want to allow the text, but not the link. If you guys are familiar with myspace and have tried to put a link to another site, the myspace site automatically changes it to something else or blank. Thus allowing the user to post the site url, but without the link. ??? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/72656-solved-removing-url-link-from-text-field/ Share on other sites More sharing options...
snowman15 Posted October 10, 2007 Share Posted October 10, 2007 if your users are imputting html tags inside of the form to make the link, I am pretty sure you can use: <?php $string=strip_tags($string); ?> correct me if I'm wrong? Quote Link to comment https://forums.phpfreaks.com/topic/72656-solved-removing-url-link-from-text-field/#findComment-366374 Share on other sites More sharing options...
monkeybidz Posted October 11, 2007 Author Share Posted October 11, 2007 Well, i used this: $sbrow_off["sb_myself"]=strip_tags($sbrow_off["sb_myself"]); It does the job, except it also removes any other html code like backround color font sizes and so on. This is for a users profile like myspace where the user can enter html code in the profile area. I need to remove URL's from string. Quote Link to comment https://forums.phpfreaks.com/topic/72656-solved-removing-url-link-from-text-field/#findComment-366832 Share on other sites More sharing options...
darkfreaks Posted October 11, 2007 Share Posted October 11, 2007 <?php $string=strip_tags($string,'<allowed tags>'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/72656-solved-removing-url-link-from-text-field/#findComment-366834 Share on other sites More sharing options...
monkeybidz Posted October 11, 2007 Author Share Posted October 11, 2007 That's a tough one,since i don't know what a user will use. Usually they probably will use the following characters in there HTML: <>,./?' ; :\|]}[{=+-_)(*&^%$#@!`~" What i really need to block or remove is: a href Quote Link to comment https://forums.phpfreaks.com/topic/72656-solved-removing-url-link-from-text-field/#findComment-366837 Share on other sites More sharing options...
darkfreaks Posted October 11, 2007 Share Posted October 11, 2007 <?php $string=str_replace('<a href="">', '',$string);?> Quote Link to comment https://forums.phpfreaks.com/topic/72656-solved-removing-url-link-from-text-field/#findComment-366839 Share on other sites More sharing options...
monkeybidz Posted October 11, 2007 Author Share Posted October 11, 2007 I changed it a bit, and it did the trick. $string=str_replace('a href=" ', '',$string);?> Your the man! Quote Link to comment https://forums.phpfreaks.com/topic/72656-solved-removing-url-link-from-text-field/#findComment-366845 Share on other sites More sharing options...
darkfreaks Posted October 11, 2007 Share Posted October 11, 2007 solved? Quote Link to comment https://forums.phpfreaks.com/topic/72656-solved-removing-url-link-from-text-field/#findComment-366846 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.