Andy252 Posted January 20, 2007 Share Posted January 20, 2007 How do you get PHP to verify URL in a post?I want to stop people posting http://bfsdjkbgfsdr Quote Link to comment https://forums.phpfreaks.com/topic/35005-verify-url/ Share on other sites More sharing options...
redbullmarky Posted January 20, 2007 Share Posted January 20, 2007 a mixture of [url=http://www.php.net/preg_match]preg_match[/url] and [url=http://www.phpfreaks.com/forums/index.php/board,43.0.html]regular expressions[/url] should do the trick. Quote Link to comment https://forums.phpfreaks.com/topic/35005-verify-url/#findComment-165102 Share on other sites More sharing options...
fert Posted January 20, 2007 Share Posted January 20, 2007 or you could try to open the page with fopen Quote Link to comment https://forums.phpfreaks.com/topic/35005-verify-url/#findComment-165106 Share on other sites More sharing options...
flash gordon Posted January 20, 2007 Share Posted January 20, 2007 [quote author=fert link=topic=123274.msg509264#msg509264 date=1169325932]or you could try to open the page with fopen[/quote]That's pretty slick ;) Quote Link to comment https://forums.phpfreaks.com/topic/35005-verify-url/#findComment-165114 Share on other sites More sharing options...
Andy252 Posted January 23, 2007 Author Share Posted January 23, 2007 [quote author=redbullmarky link=topic=123274.msg509260#msg509260 date=1169325000]a mixture of [url=http://www.php.net/preg_match]preg_match[/url] and [url=http://www.phpfreaks.com/forums/index.php/board,43.0.html]regular expressions[/url] should do the trick.[/quote]Do you have an example, or somewhere where I could find such a thing ? Quote Link to comment https://forums.phpfreaks.com/topic/35005-verify-url/#findComment-166917 Share on other sites More sharing options...
bibby Posted January 23, 2007 Share Posted January 23, 2007 RegEx would verify that the string format is sound, and fopen would only work in read only mode.When I scrape external site files, I use file() or file_get_contents();[code]if (!$file_get_contents($url)){ // then it's not real, or at least not accessible.}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/35005-verify-url/#findComment-166950 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.