Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/120285-php-filter-functions-for-url-validation/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.