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:
var_dump
the result, what do you get? If it never finishes loading perhaps it's just uploading? How do you know thatftp_put
finishes?fput
function. Also check your php error log