0

So I have made a new input with the name "Anaam". When users fill in their info in the input, it should go to the database. However, it will not. I have looked at youtube videos to solve this problem. I have also looked for similar questions like this on Stack Overflow. However, this is with a Wordpress database, so the inserting code is different then it usually is. Because of that, I could not find good questions on this.

My HTML code:

   <html>
      <head>

      </head>
      <body>
        <form action="" enctype="multipart/form-data" method="post">
          <input name="file" type="file"/>
          <br>
          <br>
          <input name="Anaam" type="text" placeholder="Albumnaam" class="albumnaam">
          <input name="submit" type="submit" value="Upload uw album" />

        </form>
      </body>
    </html>

As you can see, I have made an input with the name "Anaam".

My PHP code:

// ... Some data to connect with the remote FTP server, nothing to do with the database

$Anaam = $_POST["Anaam"];

if ((!$conn_id) || (!$login_result)) { 
    echo "Het spijt ons, er is momenteel geen connectie met de server.";
    // echo "Attempted to connect to $ftp_server for user $ftp_user_name"; 
    exit; 
} else {
     // echo "upload is gelukt";
}

  //Only allow zip and rar files to be uploaded
$allowed = array('zip', 'rar');
if(in_array($fileActualExt, $allowed)) {

// upload the file (in remote ftp server)
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);

// check upload status 
if (!$upload) { 
    echo "Er is iets fout gegaan, excuses voor het ongemak";
} else {

    // insert data in de database
     global $wpdb;
     $number_of_rows_inserted = $wpdb->insert('wpex_programma', [
      'naam' => $fileName,
      'Anaam' => "test"
     ]);

      var_dump($number_of_rows_inserted);

As you can see, I want to insert the values in the database wpex_programma in the column "naam" and the column "Anaam". In the column "Anaam" I want to insert the value of the variable $Anaam. Why will it still not work? It does not show any errors. It just never stops loading.

My table structure:

ferent

5
  • When you var_dump the result, what do you get? If it never finishes loading perhaps it's just uploading? How do you know that ftp_put finishes?
    – Tom J Nowell
    Commented Mar 16, 2020 at 13:11
  • the var_dump is not showing anything. It is just loading. Ftp_put normally works when I insert that one file. It does not work with what I do now. It does not show in my GUI FTP client (Filezilla) @TomJNowell
    – Parsa_237
    Commented Mar 16, 2020 at 13:20
  • Then you should not be debugging the database query, your page never reaches that point in the file. You should add more messages before that to state what's happening, specifically before and after the fput function. Also check your php error log
    – Tom J Nowell
    Commented Mar 16, 2020 at 13:23
  • @TomJNowell, I found out that the files do get uploaded to the database. But the loading takes REALLY long, do you happen to know how I can fix that?
    – Parsa_237
    Commented Mar 16, 2020 at 13:40
  • Not particularly, the php FTP extension isn't really appropriate for this stack, you should ask about that on StackOverflow
    – Tom J Nowell
    Commented Mar 16, 2020 at 13:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.