The weird part is that, first of all, the BROWSE field does NOT contain
the filename! Also, when I choose a new file with the browse button, it
is not uploaded and the content of the browse field isn't stored into
the database.
Well yeah...First of all...the browse field will not show data that is on a remote server. I assume the value of $picture is some file on the webserver. The "file" input does not accept a "value" in the way say, text inputs do. Second of all when you use the "file" input..you need to state 'enctype="multipart/form-data" '.
What I would do in your case is print out the thumbnail of the existing image and under that...print the empty "file" input. Then when the form is submitted...check to see if the file input == "" and if it does...do nothing with it. But if the "file" input contains data...then process your image.
The way I actually do it is to use the same form for adding and editing. I assume that when a form is being used for editing i will pass it the info from the database with fetch_object. So I code all my input values to be value="$row->value". If I don't pass it $row, then the inputs are empty. If I do...then they are prefilled with the sql data.
I also always have a hidden input in my forms called $newaction or something like that. Then when I include the form i do it like so...
$newaction = "adding";
include("someform.php");
Then in the form I would do something like this...
<Form action="blah.php" ...>
<input type="hidden" name="newaction" value="<? $newaction;?>
...form stuff here...
<?
if ($newaction == "adding") {
print"<input type=\"file\" name=\"image\">\n";
} elseif ($newaction == "editing") {
print"<img src=\"path_to_image.jpg\">";
print"<input type=\"file\" name=\"image\">\n";
}
Then, on the form processing page...
if ($_POST['image'] == ""){
//image is empty so don't process image
} else {
//process image...
}
Not exactly how I do it but...you get the idea..
good luck