PHP 7 Script to Get all Files From Directory and Subdirectories and Listing it From Server in Browser Full Project For Beginners

  • Post author:
  • Post category:PHP
  • Post comments:0 Comments


Welcome folks today in this blog post we will be creating a password protected webpage in browser using php 7. All the full source code of the application is shown below.




Get Started




In order to get started you need to make an index.php file and copy paste the following code







//Set the password
$password = "12345678pw"; 
//Let the user access protected content on page if the password match with the password that you have provided
if (isset($_POST["password"]) && ($_POST["password"]=="$password")) { ?>
  <h2 style="color: green;">Congratulations! You have successfully accessed the password protected content!</h2>
<?php }
//Display this content if the provided password is wrong
//Show the wrong password notice
    <h2 style="color: red;">Sorry...! The password you have provided was Wrong!</h2>
  <?php } ?>
  <h2>Enter correct password to see the protected content on this page</h2>
 <p align="center"><font color="red">
 <form id ="myForm" method="post"><p align="center">
 <input name="password" type="password" size="25" maxlength="10"><input value="Submit" type="submit"></p>

   <form action="<?php echo $_SERVER['SCRIPT_NAME'] ?>" method="post">
   <input type="submit" value="Save" />


Leave a Reply