// Cleaning utilities
function cleanUsername($uname) {
$uname=strtolower($uname);
$uname=strip_tags($uname);
// Remove anything not A to z or a number
$uname=ereg_replace("[^a-z,^0-9]","",$uname);
return $uname;
}
function cleanName($name) {
$name=trim($name);
$name=strip_tags($name);
// Remove anything not A to z or a space
$name=ereg_replace("[^a-z,^A-Z, ]","",$name);
return $name;
} function cleanNumber($number) {
// Remove any non-numeric characters
$number=ereg_replace("[^0-9]","",$number);
return $number;
}function cleanTimestamp($clean) {
$clean=ereg_replace("[^0-9,:,-]","",$clean);
return $clean;
}
function cleanHour($clean='1') {
$clean=intval($clean);
if($clean>23 || $clean=='')
$clean=0;
$clean=str_pad($clean,2,"0",STR_PAD_LEFT);
return $clean;
}
function cleanMinute($clean="00") {
$clean=intval($clean);
if($clean>60 || $clean=='')
$clean=0;
$clean=str_pad($clean,2,"0",STR_PAD_LEFT); return $clean;
} function cleanAddress($address) {
$address=trim($address);
$address=strip_tags($address);
// Remove anything not A to z, a number, space, or period
$address=ereg_replace("[^a-z,^A-Z,^0-9, ,.]","",$address);
$address=addslashes($address);
return $address;
}
function cleanEmail($email) {
$email=trim($email);
$email=strip_tags($email);
$email=strtolower($email);
// Remove anything that's not a to z, a number, @ or period
$email=ereg_replace("[^a-z,^0-9,@,.,-]","",$email);
return $email;
}
function cleanPhone($phone) {
if(strlen($phone)==10)
$phone=substr($phone,0,3).".".substr($phone,3,3).".".substr($phone,6,4);
elseif(strlen($phone)==7)
$phone=substr($phone,0,3).".".substr($phone,3,4);
return $phone;
}
function cleanZip($zip) {
if(strlen($zip)==9)
$zip=substr($zip,0,5)."-".substr($zip,5,4);
return($zip);
}
function mailtoLink($email,$class='') {
$email="<a href='mailto:$email' class='$class'>$email</a>";
return $email;
}
Steve
Wade Preston Shearer wrote:
i have a form where the user must enter a 10 digit number, with no exceptions.
so, i am trying to add some code to the PHP script that will validate that the entered string is good... and, if good... proceed, but if bad... print out an error with instructions.
so far, i am using strlen to make sure that it is indeed 10 characters long.
next, i am not sure how to proceed. preg_match is a good way to check for characters, but it doesn't seem very good to have a preg_match line for every conceivable character other than numbers.
is there a string search function that says simply checks if the characters within are numeric?
-wade
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
_______________________________________________ newbies mailing list [EMAIL PROTECTED] http://phantom.byu.edu/cgi-bin/mailman/listinfo/newbies
