Hi,
I got the following code to check if the submitted url is valid.
When i enterCode:if(!preg_match('/(http):\/\/([a-z0-9]+)\.[a-z]{2,4}/i', $_POST['website'])) { echo 'wrong'; } else { echo 'oke'; }
@$.#$ = wrong
aa.aa = fine
aa.a = wrong which makes sense, but when i enter aa.aaaaaa it's also fine. This {2,4} tells it that it needs to be between 2 and 4 characters, if i enter 1 character it comes up with the error, but 5 characters is fine?
Another thing is this
aa.aa.com will validate, but aa.aa.c will also validate. Which it shouldn't do, so i try'd this.
If i understand it correctly it should check the for a-z0-9 after the http:// and then their might be another value after the. And after that you have the .com/.net But it doesn't really work..Code:if(!preg_match("/(http):\/\/([a-z0-9]*)?\.([a-z0-9-_])+\.([a-z]{2,4})/i", $_POST['website'])) {
Any idea's how i could fix these problems?





Bookmarks