rubing Posted August 19, 2008 Share Posted August 19, 2008 I need to validate a URL coming from a form (method=post), so I am using the following code: $validurl=filter_input(INPUT_POST,'website', FILTER_VALIDATE_URL); if ($validurl ===FALSE) { throw new InvalidInputException(); } It doesn't do as good of a job as I'd expect. (i know, i know, i could use pear RFC validation, blah blah blah...), If I pass in something like xkjvi://mymamma.comlhj , it is accepted without a problem. the documenation says that the following optional flags: FILTER_FLAG_PATH_REQUIRED & FILTER_FLAG_QUERY_REQUIRED ,but im not sure what they do or how i would set them, since the manual just says: Associative array of options or bitwise disjunction of flags. If filter accepts options, flags can be provided in "flags" field of array. And I have no idea what that means Quote Link to comment https://forums.phpfreaks.com/topic/120285-php-filter-functions-for-url-validation/ Share on other sites More sharing options...
DeanWhitehouse Posted August 19, 2008 Share Posted August 19, 2008 can you not make your own function using a reg-ex to check for certain chars. Quote Link to comment https://forums.phpfreaks.com/topic/120285-php-filter-functions-for-url-validation/#findComment-619701 Share on other sites More sharing options...
rubing Posted August 19, 2008 Author Share Posted August 19, 2008 Why would I do that if it's built-in? Quote Link to comment https://forums.phpfreaks.com/topic/120285-php-filter-functions-for-url-validation/#findComment-619730 Share on other sites More sharing options...
DeanWhitehouse Posted August 19, 2008 Share Posted August 19, 2008 because it's not working as well as you thought, you should of been able to answer that your self. Quote Link to comment https://forums.phpfreaks.com/topic/120285-php-filter-functions-for-url-validation/#findComment-619756 Share on other sites More sharing options...
rubing Posted August 19, 2008 Author Share Posted August 19, 2008 i'm not trying to hack my way to a solution. I am trying to learn something about coding php and taking advantage of its built-in functions. Maybe, I'm not doing something right, maybe there's something that can be done with the optional flags. I don't ven know what there there for or how to set them. I find that gap in my knowledge disturbing and so am asking for help. now, i just found out that the Validate url filter is no different than the parse_url function. Quote Link to comment https://forums.phpfreaks.com/topic/120285-php-filter-functions-for-url-validation/#findComment-619763 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.