<form enctype=multipart/form-data method=post action=add2db.php>
<pre>
title    <input name=title size=25>
artist   <input name=artist size=25>
year     <input name=year size=25>
picture  <input type=File name=picture size=25>
password <input type=password name=passwd size=25>
<input type=submit name=submit value=Upload>
</form>

<?

if ($submit) {

   $db = mysql_connect("localhost","root",$passwd);

   mysql_select_db("advWebProg");

   $sql = "INSERT INTO gallery (title,artist,year,picture_name) 
           VALUES ('$title','$artist','$year','$picture_name')";

   if(!mysql_db_query("advWebProg",$sql)){
     print(mysql_error());    
         exit();
   }

   if($picture_type=="image/gif" || $picture_type == "image/jpeg")
    exec("cp $picture /web/edu/sva/advWebProg/demos/mysql_eg/img/$picture_name"); 
   else print("Picture file is not of known format!");

   echo "year: $year<br>\n";
   echo "artist: $artist<br>\n";
   echo "title: $title<br>\n";
   echo "temp file: $picture<br>\n";
   echo "file name: $picture_name<br>\n";
   echo "file size: $picture_size<br>\n";
   echo "file type: $picture_type<br>\n";
   echo "<br>";
   echo "<img src=img/$picture_name><br>\n";

}

?>
<hr>
<li><a href=../php2txt.php?mysql_eg/add2db.php>Source</a>
<li><a href=http://www.devshed.com/Server_Side/PHP/User/>Tutorial</a>