Help with AlphaNumeric checker
Posted: Tue Aug 09, 2005 1:46 pm
Hey, im trying to build an alphanumeric checker which modifys a link according to its results.. im guessing the problem is in the last function.. any help will be greatly appreciated. thank you 
Code: Select all
<?php
$redirect = "http://www.mydomain.com/verify.php?verify=1";
function isAlphaNumeric( $str )
{
$originalLength = strlen( $str );
$replacedLength = strlen( preg_replace("#[^A-Za-z0-9_]#", "", $str ) );
return $originalLength == $replacedlength;
}
function isEmail( $str )
{
$originalLength = strlen( $str );
$replacedLength = strlen( preg_replace("#[^A-Za-z0-9_@.]#", "", $str ) );
return $originalLength == $replacedlength;
}
function isValid( $post )
{
if (isAlphaNumeric($_POST[$post]))
{
$redirect .= "&" . $post . "=true";
}
else
{
$redirect .="&" . $post . "=false";
}
}
isValid ("username");
echo $redirect;
?>