jimfog Posted March 27, 2013 Share Posted March 27, 2013 I just noticed-by running tests- that in order for a web address to pass the php validation url filter it MUST be accompanied by the "http" in the beginning of the url. That said www.xxxx..com will not PASS the filter. From my point of view I think I must write extra checks because the user might write the web address without the "http". What do you do in a similar situation like this? Link to comment Share on other sites More sharing options...
Rollins Posted March 27, 2013 Share Posted March 27, 2013 (edited) i would try replacing the "www." with "http://www.".... function add_http($text){// set http: on www. $text = preg_replace( '"www\."', "http://www.", $text );// remove duplicates after set $text = preg_replace( '"http://http://www\."', "http://www.", $text ); $text = preg_replace( '"https://http://www\."', "https://www.", $text );} Edited March 27, 2013 by Rollins Link to comment Share on other sites More sharing options...
jimfog Posted March 27, 2013 Author Share Posted March 27, 2013 ...and what I would do if the URL submitted by the user has already the http in it? I think I must write a conditional in this case. Link to comment Share on other sites More sharing options...
thescientist Posted March 27, 2013 Share Posted March 27, 2013 http://php.net/manual/en/function.strpos.php Link to comment Share on other sites More sharing options...
Rollins Posted March 27, 2013 Share Posted March 27, 2013 filter_validate_url should catch a http://random.com type url from what i have found.... the example you posted has a double dot...if u use that to test it could screw up the results aswell. i think.... "That said www.xxxx..com will not PASS the filter." Link to comment Share on other sites More sharing options...
jimfog Posted March 28, 2013 Author Share Posted March 28, 2013 filter_validate_url should catch a http://random.com type url from what i have found.... the example you posted has a double dot...if u use that to test it could screw up the results aswell. i think.... "That said www.xxxx..com will not PASS the filter."Forget the example with the double dot. A mistyped. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now