<?
	$mId = $_POST['mId'];
	require_once('link.php');
	mysql_select_db($database,$connect);
	
	if( ($_FILES['aPhoto']['error'][0] == UPLOAD_ERR_OK ))
	{ 
		$userfile_1 = $_FILES['aPhoto']['tmp_name'][0];
        $upfile_1 = "./pic/album_pic/".$_FILES['aPhoto']['name'][0];
          
        if( (move_uploaded_file($_FILES['aPhoto']['tmp_name'][0], $upfile_1)))
        {	
        	echo "UPLOAD DONE  " . $_FILES['aPhoto']['name'][0] ;
        }else{
			echo "UPLOAD FAIL 101 " ;
		}
	}else{
		echo "UPLOAD FAIL 102 " ;
	}
	$upfile_2 = "/pic/album_pic/".$_FILES['aPhoto']['name'][0];
	$bName = $_GET['bName'];
	
	if(	$upfile_2 == '/pic/album_pic/')
	{
		$content = addslashes(nl2br($content));
		$query1 = "INSERT INTO `Album` VALUES ('$bName','$aName','$year-$month-$day','$company',NULL)";
		mysql_query($query1,$connect);
	
	}
	else
	{
		$content = addslashes(nl2br($content));
		$query1 = "INSERT INTO `Album` VALUES ('$bName','$aName','$year-$month-$day','$company','$upfile_2')";
		mysql_query($query1,$connect);
	
	}
	
	
	$query3 = "INSERT INTO `AddModify2` VALUES ('$mId','$bName','$aName','$seq',NOW())";
	mysql_query($query3,$connect);
	
	FOREACH($_POST["song"] as $i=>$value)
	{
		$query2 = "INSERT INTO `Song` VALUES ('$bName','$aName','$i','$song[$i]')"; 
		mysql_query($query2,$connect);
	}
	
	echo "<Script language='javascript'>";
	echo "var r=confirm('是否繼續編輯此樂團發行的專輯?');";
	echo "if(r==true)";
	echo "location.href='album_num.php?bName=".$bName."';";
	echo "if(r==false)";
	echo "location.href='a_show.php?bName=".$bName."&aName=".$aName."';";
	echo "</script>";
	
?>