Hi I am quite new to php programming but I have started a new personal project which I need a bit of help/advice on it please.
This piece of code randomly picks a line within the file:
rand.php
<?php
$filename = 'file.pwf';
$how_many_to_show = 1;
if ($fileContents = file($filename)) {
shuffle($fileContents);
for ($i = 0; $i < $how_many_to_show; $i++) {
$myvariable = ($fileContents[$i]);
echo $myvariable;
}
} else {
die('Could not get contents of: ' . $filename);
}
?>
This is an example of what the 'file.pwf' file looks like:
file.pwf
qshidfe:fh2ue24
fijwsdf:fj28fr8b
gf@gfg.com:848rfuw
I want to be able o store the first part as a variable for the username and the second part as a variable as the password.
Also I need it to work with the rest of the code, how would i link rand.php within index.php using the variables?
index.php
$user = ''; //Has to be the first variable from rand.php
$pass = ''; //Has to be the second variable from rand.php
Any help at all would be highly appreciated. Thankyou
Ash King.