[EdLUG] Help 11
Andrew Ramage
a.ramage at blueyonder.co.uk
Fri May 15 15:19:32 UTC 2020
I don't know if this will work ...
I have changed the form action call to a seperate file called
"loginmusic.php" which checks the password and if it is correct assigns
"OK" to $pwd. If it is correct, the directory will be printed.
index.php
<script>
function dirmusic() {
$musicdir = array(); // declare and initialise an array like this
$dir = "Music/";
if ($_POST($pwd) == "OK")
{
if (is_dir($dir))
{
if ($dh = opendir($dir))
{
$x = document.getElementById("demo").innerHTML;
document.getElementById("demo").innerHTML = $x
. $file . "<br>";
{
while (($file = readdir($dh)) !== false)
array_push($musicdir, $file); // array_push
alters the array in place
}
closedir($dh);
}
}
}
else
{
alert("You are not allowed to download music.");
};
}
</script>
More information about the EdLUG
mailing list