Hi, I need a quick solution for my website traffic spike.. I need my script to randomly pick an account to use: something like this $account[1]=dad $pass[1]=mum $account[2]=grandma $pass[2]=grandpa $account=$account[random] $pass=$pass[random] How is that possible ?
last 2 vars have to have dirrerent names you will want to generate a random number round to say 3 decimal places do if number > 0 and .333 some other number = 1 and so on and then do eval("$account_data = $account[" . $random2 . "];");
Will this work ? $acc[1]= $pass[1]= $acc[2]= $pass[2]= $random = rand(1, 2); $login = $acc[" .$random. "]; $pass = $pass[" .$random. "];
My dear Friend er1cw, Why don't you run the script and get the answer whether it works or not? If it doesn't let us know. We will try to help. Thanks. Coolsaint.
Would like to clarify. I wish to made something like this $random= rand(1, 2); $account[1]=dad; $pass[1]=mum; $account[2]=grandma; $pass[2]=grandpa; $login=$account[1]; or $account[2]; ( depends on $random ) $password=$pass[1]; or $pass[2]; ( depends on $random ) if $login=$account[1], $password must be $pass[1]. And so on... how can i achieve that ?
$account[1]="dad"; $pass[1]="mum"; $account[2]="grandma"; $pass[2]="grandpa"; $use = rand(1,2); if ($loginname==$account[$use] and $loginpass==$pass[$use]) { ... }
It would probably be more appropriate to use the array_rand function. $accounts = array (); // Initialise to avoid code injection $accounts[] = array ('u' => 'mom', 'p' => 'momspassword'); $accounts[] = array ('u' => 'dad', 'p' => 'dadspassword'); $accounts[] = array ('u' => 'grammma', 'p' => 'herpassword'); $account_index = array_rand ($accounts); list ($username, $password) = $accounts[$account_index]; // Now use the $username adn $password variable here PHP: