1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Password Combination

Discussion in 'PHP' started by cashflowtips, Sep 10, 2007.

  1. #1
    im looking for solution on how to check the password combination...

    here is the example: -

    $text = "onlyalphanumericcharacters012345";
    
    if (ereg('[^A-Za-z0-9]', $text)) {
      echo "This contains characters other than letters and numbers";
    }
    else {
      echo "This contains only letters and numbers";    
    }
    PHP:
    but the problem here is - i want the code only accept with these kind of combination: -

    a) alphabet + number
    b) alphabet + symbol
    c) number + symbol

    can anyone help me? thanks alot
     
    cashflowtips, Sep 10, 2007 IP
  2. omgitsfletch

    omgitsfletch Well-Known Member

    Messages:
    1,222
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    145
    #2
    You might also want to define what symbols are allowed. Keep in mind with alt codes and everything else you can get a lot more symbols than you see on the face of your keyboard.
     
    omgitsfletch, Sep 10, 2007 IP
  3. cashflowtips

    cashflowtips Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i want the general accepted symbol that used by many sites to make password more stronger. but that is not the biggest problem. can you show me how to do the combination?
     
    cashflowtips, Sep 10, 2007 IP
  4. omgitsfletch

    omgitsfletch Well-Known Member

    Messages:
    1,222
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    145
    #4
    You're best bet is to have it do three separate regexes, I would think. Something like:

    <?
    
    $password = "onlyalphanumericcharacters012345";
    
    if (ereg('^([A-Za-z0-9]){8,20}$', $password) || (ereg('<alpha+symbol regex>', $password) || (ereg('<number+symbol regex>', $password))
       echo 'This password is in the correct format';
    else 
       echo 'This password is not in the correct format';   
    
    ?>
    PHP:
    I would help with the last two regexes, but I'm way too tired, so hopefully another member can help me out. But the code surrounding it will check that it passes for ONE of the regexes, otherwise it will fail.
     
    omgitsfletch, Sep 10, 2007 IP
    webrickco likes this.
  5. cashflowtips

    cashflowtips Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    owh... thanks alot... anyone here willing to continue this code?
     
    cashflowtips, Sep 10, 2007 IP
  6. cashflowtips

    cashflowtips Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    maybe my question is not very clear and i want to apologize for that... let me explain once again...

    what i really want is the code that can check where the input must have

    a) must have Alphabet + must have Number (if the input only one of these two, it will return false)
    b) must have Alphabet + must have Symbol (the condition same as A(above))
    c) must have Number + must have Symbol (the condition same as A(above))
    d) can have ALL

    as for the Symbol, im not sure what is the basic one that usually been used by other website but i know some of them accept symbol as password characters to increase security (hard for hacker to guess the password)
     
    cashflowtips, Sep 10, 2007 IP