problems with ctype_alnum() function

adbask
12:06:14
I am using this function



if(!isset($username) or strlen($username) <3){
$msg=$msg."User id should be =3 or more than 3 char length<BR>";
$status= "NOTOK";}

if(!ctype_alnum($username)){
$msg=$msg."User id should contain alphanumeric chars only<BR>";
$status= "NOTOK";}





At one point it was working just fine I haven't changed anything and then suddenly it started giving me the error message:

[quote]User id should contain alphanumeric chars only[/quote]

No matter what username a enter it still gives me that error message.
I have tried all combinations of usernames.
alpha and alphanumeric but the same thing happens.
Any ideas please any suggestions ?
Thanks

smo1234
12-09-2014
Have you tried by removing blank space. At the end of this page it is added now.
http://www.plus2net.com/php_tutorial/ctype_alnum.php

Before using the variable $username , try to print out and see what you are getting. If you are using Ajax then add the variable to the message string and see the correct data is going to script or not.

$msg=$msg."User id ( $username )should contain alphanumeric chars only<BR>";

This way you can see what is finally going to the script.

Let us know the result.
Please Login to post your reply or start a new topic