M0B2 Posted April 19, 2011 Share Posted April 19, 2011 I've been trying to secure the register page on the lite version of MCCodes. The bit im interested in is making sure that when people register a new user they can only have numbers or letters in the username, but I to be honest I just dont know how to do it. The lite versions allows I think all characters including special ones (e.g. * , ; @). Any help would be appreciated thanks. Quote Link to comment Share on other sites More sharing options...
rulerofzu Posted April 19, 2011 Share Posted April 19, 2011 filter sanitize/validate preg match are two ways you can do this. I have never downloaded lite so I am unable to state exactly where. Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted April 19, 2011 Share Posted April 19, 2011 you can use simple regular expressions like: [^a-zA-Z0-9] That would match any NON allowed character and therefore trigger your filter or [^\d\w] For the PHP code: $username="toto"; $badUsername="bad!one"; $pattern="/[^a-zA-Z0-9] /"; if(preg_match($pattern,$username) != 0) // not a good one! echo "$username is not an accepted username<br />"; else echo "welcome in the game $username<br />"; if(preg_match($pattern,$badUsername) != 0) // not a good one! echo "$badUsername is not an accepted username<br />"; else echo "welcome in the game $badUsername<br />"; Quote Link to comment Share on other sites More sharing options...
M0B2 Posted April 22, 2011 Author Share Posted April 22, 2011 Where would i add this?, i mean should i add it in parts of just copy and paste the whole thing in? (Sorry for the noobish question :)) Quote Link to comment Share on other sites More sharing options...
Danny696 Posted April 22, 2011 Share Posted April 22, 2011 Mabey you should learn PHP before even thinking about owning a game. Then you'll be able to make it unique ;) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.