Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder
    Join Date
    Jun 2009
    Posts
    351
    Thanks
    75
    Thanked 0 Times in 0 Posts

    need some logic for a simple problem

    hi guys

    usename: password
    user1: pass1
    user2: pass2
    user3: pass2


    i have a function fun(username,pass) and i want to run it for lots of different user names and passwords. what would the best way to do this?

    would i make an array and use a foreach loop or how would i do it and what could would i need??

  • #2
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,383
    Thanks
    264
    Thanked 32 Times in 31 Posts
    i always kinda cringe when someone wants to run scripts on usernames and passwords... care to share why u want to do this..

  • #3
    Regular Coder
    Join Date
    Jun 2009
    Posts
    351
    Thanks
    75
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by durangod View Post
    i always kinda cringe when someone wants to run scripts on usernames and passwords... care to share why u want to do this..
    baically i have a function to log into face book and post something to my wall and i have 4 accounts so i want the script to do it for all 4 accounts

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,854
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Save them in an array (encrypted form?) and use the in_array() function to check for the existence.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    Regular Coder
    Join Date
    Jun 2009
    Posts
    351
    Thanks
    75
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by abduraooft View Post
    Save them in an array (encrypted form?) and use the in_array() function to check for the existence.
    im not sure how to right it. can you help me write the code in php please?

    and how will i loop throught the accounts?

  • #6
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts

  • #7
    Regular Coder
    Join Date
    Jun 2009
    Posts
    351
    Thanks
    75
    Thanked 0 Times in 0 Posts
    so would it be like this?

    PHP Code:
    $accounts = array("user1""user2""user3""user4");

    foreach(
    $accounts as $account)
    {
    function(
    $account)


  • #8
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Code:
    $accounts = array(
    'user1'    =>    'password',
    'user2'    =>    'password',
    'user3'    =>    'password',
    'user4'    =>    'password'
    );
    
    foreach($accounts as $name => $pass)
    {
        function($name, $pass)
    }

  • #9
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,854
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    If you are not using any encryption, then you may do it simply like
    PHP Code:
    $key=$_POST['username'].':'.$_POST['password'];
    $accounts = array("user1:pass1""user2:pass2""user3:pass3""user4:pass4");
    if(
    in_array($key,$accounts )){
    //authenticate.

    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •