Advertisement
Chrizz93

Untitled

Apr 28th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.35 KB | None | 0 0
  1. <html>
  2.     <body>
  3.         <form method="POST">
  4.             <input type="file" name="fileup">
  5.             <input type="submit" name="upload" value="Upload">
  6.         </form> <br>
  7.         <?php
  8.         $servername = "localhost";
  9.         $username = "root";
  10.         $password = "";
  11.         $database = "skp";
  12.  
  13.         $conn = new mysqli($servername, $username, $password, $database);
  14.  
  15.         if ($conn->connect_error) {
  16.             die("Connection failed" . $conn->connect_error);
  17.         }
  18.         ?>
  19.         <?php
  20.         $sql_select = "SELECT * FROM upload";
  21.         $result = $conn->query($sql_select);
  22.  
  23.         if ($result->num_rows > 0) {
  24.             while ($row = $result->fetch_assoc()) {
  25.                 echo ('');
  26.                 ?>
  27.                 <form action="filer/<?php echo $row['content']; ?>">
  28.                     <input type="submit"   value="Se Filen">
  29.                 </form>
  30.                 <?php
  31.             }
  32.         }
  33.         ?>
  34.  
  35.         <?php
  36.         if (isset($_POST['upload'])) {
  37.             $sql_insert = "INSERT INTO upload (name,text,content) VALUES ('" . '' . "','". '' . "','" . $_POST['fileup'] . "')";
  38.             if ($conn->query($sql_insert) === TRUE) {
  39.                 echo "Filen er uploadet! ";
  40.             } else {
  41.                 echo "Fejl";
  42.             }
  43.         }
  44.         ?>
  45.     </body>
  46. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement