...

View Full Version : need some logic for a simple problem



kevinkhan
11-22-2010, 02:10 PM
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??

durangod
11-22-2010, 02:26 PM
i always kinda cringe when someone wants to run scripts on usernames and passwords... care to share why u want to do this..

kevinkhan
11-22-2010, 02:28 PM
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

abduraooft
11-22-2010, 02:52 PM
Save them in an array (encrypted form?) and use the in_array() function to check for the existence.

kevinkhan
11-22-2010, 05:34 PM
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?

MattF
11-22-2010, 05:46 PM
http://uk.php.net/manual/en/function.in-array.php
http://uk.php.net/manual/en/control-structures.foreach.php

kevinkhan
11-22-2010, 06:00 PM
so would it be like this?


$accounts = array("user1", "user2", "user3", "user4");

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

MattF
11-23-2010, 12:23 AM
$accounts = array(
'user1' => 'password',
'user2' => 'password',
'user3' => 'password',
'user4' => 'password'
);

foreach($accounts as $name => $pass)
{
function($name, $pass)
}

abduraooft
11-23-2010, 09:05 AM
If you are not using any encryption, then you may do it simply like

$key=$_POST['username'].':'.$_POST['password'];
$accounts = array("user1:pass1", "user2:pass2", "user3:pass3", "user4:pass4");
if(in_array($key,$accounts )){
//authenticate.
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum