It succeeds me but not for a photo to add to an update page. Even a brief overview:
-- On page 1, only a few fields (name, password, city). No pictures.
-- Only on the update page the remaining information required. Even the photos.
-- Everything is updated, only the photos are not added to the database, or stored in a folder.
This is the update page:
<?php
// variabelen initialiseren:
$username = "dotserv_2";
$password = "rFVzsRK5";
$host="localhost";
$dbnaam="dotserv_gazelle";
$db=mysql_connect($host, $username, $password) or die (mysql_error());
mysql_select_db($dbnaam, $db) or die (mysql_error());
$id = $_GET["id"];
if (isset($_POST["bevestiging"])){
mysql_query("INSERT INTO `gaz_main_algemeen` (``,`file1',`file2',`file3`,'file4') VALUES ('','$_FILES[0]','$_FILES[1]','$_FILES[2]','$_FILES[3]');");
$files = array();
foreach ($_FILES["pictures"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["pictures"]["tmp_name"][$key];
$name = $_FILES["pictures"]["name"][$key];
move_uploaded_file($tmp_name, "images/$name");
array_push($files, $name);
}
}
// make query
$query="UPDATE gaz_main_algemeen SET
Name = '". $_POST["Name"] ."',
pass1 = '". $_POST["pass1"] ."',
pass2 = '". $_POST["pass2"] ."',
wachtwoord = '". $_POST["wachtwoord"] ."',
status = '". $_POST["status"] ."',
email = '". $_POST["email"] ."',
actief = '". $_POST["actief"] ."',
actcode = '". $_POST["actcode"] ."',
lastactive = '". $_POST["lastactive"] ."',
typ_of_acc = '". $_POST["typ_of_acc"] ."',
cat_of_acc = '". $_POST["cat_of_acc"] ."',
file1 = '". $_FILES["file1"]['name'] ."',
file2 = '". $_FILES["file2"]['name'] ."',
file3 = '". $_FILES["file3"]['name'] ."',
file4 = '". $_FILES["file4"]['name'] ."',
etc...
WHERE id='" .$_POST["id"] ."'";
$result = mysql_query($query) or die ("FOUT: " . mysql_error());
if ($result){
echo ("your id-number " .$_POST["id"] . " is changed<br>\n");
echo ("Klik na het terugkeren op vernieuwen om de veranderingen te zien.<br><br>\n");
echo ("<a href='javascript:history.back();'>Terug</a>");
}
}else{
// pagina heeft zichzelf nog niet aangeroepen,
// formulier tonen om gegevens te bewerken
$query="SELECT * FROM gaz_main_algemeen WHERE id='" . $_GET["id"] ."'";
$result = mysql_query($query) or die ("FOUT: " . mysql_error());
?>
<html>
<head>
<title></title>
</head>
<body>
<?php
while (list($ID, $Name, $pass1, $pass2, $wachtwoord, $status, $email, $actief, $actcode, $lastactive, $typ_of_acc, $cat_of_acc, $file1, $file2, $file3, $file4, etcetera) =
mysql_fetch_row($result)){
$nam=$Name;
$pss1=$pass1;
$pss2=$pass2;
$wawo=$wachtwoord;
$stat=$status;
$mail=$email;
$actie=$actief;
$actcd=$actcode;
$lastact=$lastactive;
$t_o_a=$typ_of_acc;
$c_o_a=$cat_of_acc;
$fl1=$file1;
$fl2=$file2;
$fl3=$file3;
$fl4=$file4;
etcetera;
}?>
<form action="<?php echo($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data" method="post">
<input type="hidden" name="id" value="<?php echo($_GET["id"]);?>">
<input type="file" name="pictures[]" /><br>
<input type="file" name="pictures[]" /><br>
<input type="file" name="pictures[]" /><br>
<input type="file" name="pictures[]" />
<input type="Submit" value="Update" name="Update">
<input type="Button" value="Back" onClick="javascript:history.back(-1);">
</form>
<?php
}
?>
</body>
</html>
The pictures go to the picture-map, but not to the database.
Did somebody now what's wrong? Why don't the pictures uploaded?