PHP registation checking

Discussion in 'PHP' started by bkflash, Nov 16, 2006.

  1. #1
    So im making my own registration form and i have it so they enter there username and password that is desired. But ive noticed with the bigger sites it won't let you have a username with a password that are similar to each other, does anybody know of a coding that would make it so user couldn't have similar enteries like that?

    thanks , brandon
     
    bkflash, Nov 16, 2006 IP
  2. ajscottsr

    ajscottsr Peon

    Messages:
    388
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I don't know right off. I've never written anything to do that.

    After a few seconds thought though, I could think of one possible way to do it. You could always run through a loop and take each possible series of 4 consecutive characters in the username and compare it to the psasword.

    For example, if the username is ajscottsr, you could compare the password to see if it contains ajsc, jsco, scot, cott, otts, ttsr and reject it if you hit a match.

    I'm sure there are plenty of other ways, perhaps some better. That's just one possible suggestion that I could think of after giving it 30 seconds thought.
     
    ajscottsr, Nov 16, 2006 IP
  3. streety

    streety Peon

    Messages:
    321
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #3
    It is easy enough to check whether their password is the same as their username but picking up small differences could be hard. It depends how strict you want the test to be.

    A good place to start might be looking for a fragment (substring) of one value in the other. A substring of 3 characters or more you might want to avoid while 2 character substrings are probably acceptable.

    [edit]Looks like ajscottsr beat me to it. I guess thats what happens when you get distracted while posting.[/edit]
     
    streety, Nov 16, 2006 IP
  4. Seph

    Seph Peon

    Messages:
    84
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Luckily I'm a walking php function reference lookup and remembered a few functions which might help you.

    php.net/levenshtein
    php.net/similar-text
     
    Seph, Nov 16, 2006 IP
    streety and ajscottsr like this.
  5. ajscottsr

    ajscottsr Peon

    Messages:
    388
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I need one of those (walking php reference function lookup) :)

    Very cool functions indeed - rep to ya...

    As I said in my response, that was 30 seconds of thinking to come up with that solution. When/if the time comes to actually use something like that, no doubt a search to php.net and/or other respectable sources would have occurred first :).
     
    ajscottsr, Nov 17, 2006 IP
  6. bkflash

    bkflash Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    k thanks guys that helps my situation alot
     
    bkflash, Nov 17, 2006 IP