PHP, validation and regex

Hello everyone - I’ve a little question because I’m a little lost, I’m sitting here with a contact form, and need to server-side validate it. But the reason is I don’t really know how to do it, I have a field in the form called URL, that should validate an URL, so I though I could use the FILTER_VALIDATE_URL - But when I use it, it validates the URL if there is http:// in front of the address, but doesn’t if it’s just like www.domain.com - it needs to be http://www.domain.com - Is there any way to get around this using the FILTER_VALIDATE_URL? or should I use the FILTER_VALIDATE_REGEXP and then paste a perl-compatible URL regex?

or is there other ways doing it more easy? - I don’t know how to use the pattern-things because I’m still a beginner tho :shifty:

You could run the url through parse_url and check that it has a scheme.
If it doesn’t have a scheme, you could then prepend one to the url and then pass that combination through for validation.

Thank you both for the answer, I will try it out a little later today.

Thanks again:D