Thanks for all the information.
I am attempting to build a phonetic database for one of our professors at work. Through PHP he and a couple of other people should be able to upload wav/mp3 files to the server and in addition tag the files with phonetic related information. In addition to upload one file at a time the script should also let the users upload multiple files to the server in one operation and give these files the same tag info. This is for cases where wav/mp3 content is different but the metadata should be the same.
But the script below is still very much in the beginning stage of the end target. Im currently trying to understand how to properly insert data from user input into a mysql table from an html form.
Anyway, I have updated the script and tried to accommodate your suggestions about security and such. Im shure there are still much room for improvement so please feel free to comment so I can make it better.
<?php
$connect = mysqli_connect("localhost","user","pass","database");
if (mysqli_connect_errno()) {
mysqli_connect_error();
exit();
}
echo "<a href=./>Home</a><br>";
$query = mysqli_query($connect, "SELECT filename,dato,size,spoken,speaker,dialect,project,gender FROM pdb ORDER BY id LIMIT 1") or die (mysqli_connect_error());
$fetch_data = mysqli_fetch_array($query, MYSQLI_ASSOC);
foreach($fetch_data as $value) {
$values = $_REQUEST[$value];
}
if (empty($_POST)) {
echo "<form method='post' action='".$_SERVER['PHP_SELF']."'>";
echo "<table border='1'>";
foreach($fetch_data as $key => $value) {
echo "<tr><td>" . htmlspecialchars($key) . "</td><td><input type='text' name='" . htmlspecialchars($value) . "[]'></td></tr>";
}
echo "</table>";
echo "<input type='submit' value='Insert'>";
echo "<input type='button' onclick='history.go(-1)' value='Cancel'>";
echo "</form>";
}
else {
$query="INSERT INTO pdb (filename,dato,size,spoken,speaker,dialect,project,gender) VALUES ('$values[0]','$values[1]','$values[2]','$values[3]','$values[4]','$values[5]','$values[6]','$values[7]')";
mysqli_query($connect,$query) or die (mysqli_error($connect));
$affected_rows = mysqli_affected_rows($connect);
echo "<strong>".$affected_rows."</strong> row inserted.";
}
mysqli_close($connect);
?>