Topic: quick easy php validation question?
Im putting in url validation.
Is this...
if (preg_match("/^(http(s?):\/\/|ftp:\/\/{1})((\w+\.){1,})\w{2,}$/i", $website)) {
echo "Valid URL";
}
else {
echo "Invalid URL";
}
the same as this...
if (!preg_match("/^(http(s?):\\/\\/|ftp:\\/\\/{1})((\w+\.)+)\w{2,}(\/?)$/i", $website)) {
header( "Location: $errorurl" );
exit ;
}
Note, I just added the "!" infront of preg_match and went strait to the error. Am I right here?
