<?
$id_edit=$_POST['id_edit'];
$type=$_POST['type'];
$title_album=$_POST['title_album'];
$artist_album=$_POST['artist_album'];
$detail_album=$_POST['detail_album'];
$chkdel=$_POST['chkdel'];
$photo=$_FILES['photo']['tmp_name'];
$photo_name=$_FILES['photo']['name'];
$photo_size=$_FILES['photo']['size'];
$photo_type=$_FILES['photo']['type'];
include "connect.php";
if ($chkdel=="1") {
$sql="update album set picture_album='' where id_album='$id_edit' ";
mysql_db_query($dbname,$sql);
unlink("photoalbum/$photo_del");
}
if ($photo) {
$ext = strtolower(end(explode('.', $photo_name)));
if ($ext == "jpg" or $ext == "jpeg" or $ext=="gif" or $ext=="png") {
$filename=$id_edit.".".$ext;
copy($photo,"photoalbum/$filename");
$sql="update album set picture_album='$filename' where id_album='$id_edit' ";
mysql_db_query($dbname,$sql);
}
}
$sql="update album set
type='$year_album',title_album='$title_album',artist_album='$artist_album',detail_album='$detail_album' where id_album='$id_edit' ";
$result=mysql_db_query($dbname,$sql);
if ($result) {
echo "<h3>แก้ไขเสร็จเรียบร้อย</h3>";
echo "[ <a href=album.php>Back</a> ] ";
} else {
echo "<h3>ไม่สามารถแก้ไขได้</h3>";
}
mysql_close();
?>