I would rather use the PCRE functions as I feel they are more efficient. You can also use something like the following approach to avoid doing the eregi twice,
PHP Code:
$clean = array();
$errors = array();
if ( isset($_POST['username']) ) {
if ( preg_match('/^[a-z0-9]+$/i', $username) ) {
$clean['username'] = $username;
} else {
array_push($error, 'Username must be alpha numberic');
}
} else {
array_push($error, 'Username is a required field');
}
if ( isset($clean['username']) {
// Do login stuff
} else {
foreach ( $errors as $error ) {
echo "$error";
}
}
I would move/avoid the make_safe function until you get to the database abstraction layer.
--
lv
Bookmarks