PHP code just does not start when loading page!

0

I made the code below to show the files that were inserted by the user, however it only shows the files after having attached a file, however I wanted it to show when loading the page, for the user to see what files he has already done Upload. Here is the code I used to upload the file:                     

Lesson Plan 1

                                                        
    $arq = str_replace(" ", "_", $arq);
    $arq = str_replace("ç", "c", $arq);

    if (file_exists("uploads/".$arq)) {
      $a = 1;

      while (file_exists("uploads/[".$a."]".$arq)) {
        $a++;
      }

      $arq = "[".$a."]".$arq;
    }

    if (move_uploaded_file($_FILES['arquivo']['tmp_name'], 'uploads/'.$arq)) {
      $objDb = new db();
      $link = $objDb->conecta_mysql();
      $sql = "insert into arquivos (email_vol, nomearq) values ('".  $email."', '".$arq."')";
      if (mysqli_query($link, $sql)){
        echo 'Plano de aula 1 enviado com sucesso!';
      } else {
        echo (mysqli_error($link));
        echo 'Erro ao enviar o plano de aula!';
      }

    } else {
      echo "Nenhum arquivo selecionado!";
    }

  }
  ?>
</p></center>

Here is the code to show the file on the page:

<div class="container">
  <div class="text-center">
       <h1 class="tittlenoticia" style="color: black;">Arquivos anexados</h1>
       <?php
       require_once('conecta.php');
       $pasta = "uploads/";
       $consulta = mysqli_query($link, "SELECT * FROM arquivos WHERE email_vol = '$email'");
        while ($resultado = mysqli_fetch_array($consulta)) {
            echo "<a href=\"" . $pasta . $resultado["nomearq"] . "\">" . $resultado["nomearq"] . "</a><br />";
        } 
       ?>

  </div>
</div>

Can anyone give me a hand? Thanks in advance.

    
asked by anonymous 25.10.2017 / 16:19

0 answers