Advertisement
Guest User

Untitled

a guest
Oct 7th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.82 KB | None | 0 0
  1. <?php
  2.  
  3. $dbhost = 'localhost';
  4. $dbuser = 'admin';
  5. $dbpass = 'root';
  6. $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
  7.  
  8. $dbname = 'files';
  9. mysql_select_db($dbname);
  10.  
  11.  
  12. mysql_query("TRUNCATE files_tbl");
  13. $thelist='';
  14. if ($handle = opendir('./pdf/')) {
  15.     while (false !== ($file = readdir($handle)))
  16.     {
  17.         if ($file != "." && $file != ".."){
  18.  
  19.             if ( ($file = @scandir('./pdf/') && (count($file) > 0) ) ) {
  20.  
  21.                 try{
  22.                     $thelist .= '<font face="Calibri" size="4"><p><b><img src="images/document.png"> '.$file.'<br></b></p></a></font>';
  23.                     $query = "INSERT INTO files.files_tbl(Name) VALUES ('$file');";
  24.                     mysql_query($query) or die('Error, Insert query failed' . mysql_error());
  25.                 }catch (Exception $e){
  26.                     die ($e->getMessage);
  27.                 }
  28.             }else{
  29.                 die($thelist = '<font face="Calibri" size="4"><p><b><img src="images/document.png"> No Files In Database <br></b></p></a></font>');
  30.             }
  31.  
  32.        }
  33.  
  34.     }
  35.  
  36.   closedir($handle);
  37. }
  38.  
  39.  
  40. ?>
  41.  
  42. <html>
  43.     <head>
  44.     <link rel="stylesheet" href="style.css" type="text/css">
  45.         <title>Search the Database</title>
  46.     </head>
  47.  
  48.     <body>
  49.  
  50.     <div align="right"><form action="search.php" method="post">
  51.     <div align="left"><font face="Arial" size="8" ><b>Document Database</b> </font></div>
  52.      <font face="Arial" size="5px" ><b> Search: <input type="text" name="term" style="border:1px dashed #216DAB"/></b></font>
  53.  
  54.     &nbsp;
  55.  
  56.     <input type="image" src="images/search1.png"  name="submit" value="Search" align="right"/>
  57.     </form>
  58.     <hr size="20" noshade="noshade" color="#216DAB">
  59.     </div>
  60.     </body>
  61. </html>
  62.  
  63. <P><font face="Arial" Size="6px" color="black" ><b>List of files</b></font></p>
  64. <P><center><table border="0" bgcolor="#E0E0E0" style="border:1px dotted black"><td><?=$thelist?></td></table></center></p>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement