Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

php + validating a password in a form

  • 19-06-2008 09:36AM
    #1
    Registered Users, Registered Users 2 Posts: 788 ✭✭✭


    Hi there,

    I'm creating a form to register a user, I'd like the user's password to be alphanumeric, and if its not, to display an error message. I can't seem to find any functions that deal with this in a simple way. Anyone have any ideas/suggestions I'd really appreciate it :)


Comments

  • Registered Users, Registered Users 2 Posts: 68,173 ✭✭✭✭seamus


    preg_match() would probably be your man. Have a look at regular expressions.

    The Regex

    /^[A-Za-z0-9]*$/ will match all alphanumeric strings.

    It can also be written as /^[:alnum:]*$/ but for some reason I find the former easier to read.


Advertisement