You might want to pass $redirect by reference to isValid() instead, e.g.
function isValid(&$redirect, $post)
{
if (isAlphaNumeric($_POST[$post]))
{
$redirect .= "&" . $post . "=true";
}
else
{
$redirect .="&" . $post . "=false";
}
}
Incidentally, it doesnt make sense to find the length of a string to be tested, then test and replace the unwanted characters with zero length strings, and then compare the length again. It is easier to just test for the unwanted characters, e.g.
function isAlphaNumeric($str)
{
return !preg_match("#[^A-Za-z0-9_]#", $str);
}