Jump to content

[SOLVED] Code rewrite help needed


acctman

Recommended Posts

I would like to have the code re-written so that it will rejects all characters that are not A-Z,a-z,0-9.

 

please do not reply if you do not wish to help out.

thanks.

 

//illegal characters in username?
        $illegal = array('#','?','&','"','/','%','!','$','\'','*','-','_','~');
        foreach ($illegal as $value)
            if (strpos($en['user'],$value) !== false)
                $ill = true;

        if ($ill)
            $err .= _reg_illegal.'<br>';

Link to comment
https://forums.phpfreaks.com/topic/89944-solved-code-rewrite-help-needed/
Share on other sites

Then you want to check if the username is alphanumeric. Use ctype_alnum():

 

<?php
//illegal characters in username?
        if (!ctype_alnum($en['user']))
            $err .= _reg_illegal.'<br>';
?>

 

wow that's it, using !ctype_alnum takes care of everything?  that really shorten the coding by a lot.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.