Thank you for the help. It seems to bypass the login piece of the script and still display the files with no auth. Also is there a way to only list a certain type of fiels in the directory? Such as only list the files that ahve a pdf extention? This is the script I have so far.
<?php
session_start();
// Define your username and password
$username = "Fileuser";
$password = "test98";
if (!isset($_SESSION['loggedIn'])) {
$_SESSION['loggedIn'] = false;
}
if (isset($_POST['txtUsername']) && isset($_POST['txtPassword'])) {
if ($_POST['txtUsername'] === $username && $_POST['txtPassword'] === $password) {
$_SESSION['loggedIn'] = true;
}
}
if ($_SESSION['loggedIn']) {
// list your files
$dir = ".";
$dh = opendir($dir);
while (($file = readdir($dh)) !== false) {
echo "<A HREF=\"$file\">$file</A><BR>\n";
}
closedir($dh);
//end list files
}
else {
// display the login form
?>
<h1>Login</h1>
<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<p><label for="txtUsername">Username:</label>
<br /><input type="text" title="Enter your Username" name="txtUsername" /></p>
<p><label for="txtpassword">Password:</label>
<br /><input type="password" title="Enter your password" name="txtPassword" /></p>
<p><input type="submit" name="Submit" value="Login" /></p>
</form>
<?php
} // end display the login form
Thanks!