Assignment 3 : B2

SET B : B2


<!DOCTYPE html>
<html>
<head>
 <title>B2</title>
 <style type="text/css">
 g{color:gray;}
 m{color:red;font-family:comic sans ms;font-weight:bold;}
 </style>
</head>
<body>
 <fieldset><legend><g><b>&nbsp Search files here &nbsp</b></g></legend>
 <form method="POST">
  <tr>
  <td><b>Enter Directory Path :&nbsp</b><input type="text" name="dir1"></td><br/><br/>
  <td><b>Enter Extention : &nbsp</b><input type="text" name="ext"></td><br/><br/>
  <td><input type="submit" name="submit"></td><hr/>
  </tr>
 </form>
</body>
</html>


<?php
 if(isset($_POST['submit']))
 {
  echo "<m>";
  $dir1=$_POST['dir1'];
 $ext=$_POST['ext'];
 if(is_dir($dir1))
 {
  $hndl=opendir($dir1);
  while(($file=readdir($hndl))!=false)
  {
   if(strpos($file,$ext,1))
   {
    echo "$file<br/>";
   }
  }
 }
 closedir($hndl);
 echo "</m>";
 }
?>


Comments

Popular posts from this blog

T.Y.BSc Computer Science PHP Assignment