chris_s_22 Posted November 27, 2009 Share Posted November 27, 2009 im trying to validate url's sent to me by a form the url's im collecting are for placing banners on my site so the url's are the link to there site and url of where there banner is URL's ARE BROKEN INTO PARTs PROTOCOL/SUBDOMAIN/DOMAIN NAME/DIRECTORY/FILE SO FAR I GOT if(!preg_match("/^http://www.[a-z0-9-].[a-z]{2,3}[a-z0-9/.] $/i", $_POST[url])) This checks the form feild url 1) make sure http://www. is present (i dont see why it should be any different for the purpose of my use) i wll be placing a warning on my form page that the urls must contains this 2) Then my code checks it consists of only letters,numbers,dashes/hythens i read these are the only characters a domain name can be also they must start with a letter or number so how do i make that possible? 3) the next part makes sure theres a . 4) the next part makes sure it consists of only letter of 2-3 characters long this only alows things such as .com or .ru How do i alow multiple for example .co.uk 5) i then want to make the rest optional but to alow letter/numbers/for directories . for start of ext can anyone help me tweak my code to satisfy my needs but to be as strict as possible. also knowing what my code is going to be checking is there any genuine urls that the code would refuse or is there anything i need to know Link to comment https://forums.phpfreaks.com/topic/183148-validating-url/ Share on other sites More sharing options...
abazoskib Posted November 27, 2009 Share Posted November 27, 2009 also knowing what my code is going to be checking is there any genuine urls that the code would refuse or is there anything i need to know http://google.com Link to comment https://forums.phpfreaks.com/topic/183148-validating-url/#findComment-966609 Share on other sites More sharing options...
chris_s_22 Posted November 27, 2009 Author Share Posted November 27, 2009 im very aware thast it would refuse http://google.com but as i said in my post i will be making the user aware to make sure they type both http:// and the www. Link to comment https://forums.phpfreaks.com/topic/183148-validating-url/#findComment-966677 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.