Hi realcoder,
You should write a validation function that parses input when it is submitted by the user. Inside the validation function you would do something like:
PHP Code:
$hostname ='somebadmalforednonexistantdomain.com';
if( validateDomainName($hostname) == 1){
/*write $hostname to db */
} else {
/*return error code and display or don't write to db */
}
function validateDomainName($hostname = '');
$ip = gethostbyname($hostname );
if (preg_match('/^(([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/',$ip)) {
return 1;
} else {
return 0;
}
}
Quickly thrown together but something along that lines.
Regards,
Steve
Bookmarks