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.

tweak code to add more then one field log in details

Discussion in 'PHP' started by jpoke5, Nov 23, 2011.

  1. #1
    I have a chunk of code for password protect a php page but want to be able to add more then one field for this and dont know how to do it. want to be able to add as many log in details as i like for each user. the code inside of the ( ) fields has been added by me for demo reasons. how do I add $username2 $username3 and so on...> to the IF statement so it will log in user by custom password??

    thanks
    Jeff


    // Define your username and password

    $username = "user1";

    $password = "pass1";

    ($username2 = "user2"; )

    ($password2 = "pass2"; )


    if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) {
     
    jpoke5, Nov 23, 2011 IP
  2. alexfad20

    alexfad20 Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    First you should use associative array. key => value (user=>pass)
    Next you need to compare your POST results with elements of you array in a cycle
     
    alexfad20, Nov 23, 2011 IP
  3. jpoke5

    jpoke5 Active Member

    Messages:
    222
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    80
    #3
    sorry... I should have said I know very little about php. I dont understand what that means. can you show me how?

    Thanks
     
    jpoke5, Nov 23, 2011 IP