Probleme ajout titre mp3 possibilité upload

Fermé
antho - 26 oct. 2007 à 12:50
 antho - 26 oct. 2007 à 16:15
Bonjour,
Je vien de mettre en place un system de gestion de titre musique,
Si je ve donner une écoute à mon titre, j'ai mis un champ upload avec renome du fichier, le probleme, c'est que meme si je n'ai pas envoyer de fichier, il note quand meme un nom de fichier dans la base de donnée,

je voudrais qu'il renomme les fichiers seulement si j'ai uploader un fichier dans ma base

voici ma source php

<?
session_start();
include("../connection/conf.php");
include("function.php");
include("javascript.htm");
?>
<link rel="stylesheet" href="style/main.css" />
<SCRIPT LANGUAGE="JavaScript">
<!--
function go(what) {
value = what.options[what.selectedIndex].value;
if (value == '') return;
window.location.href = value;
}
//-->
</script>
<?
$page=9;
require("secu.php");
if($valide==1){
$oFCKeditor = new FCKeditor('titre_description');


if(isset($_GET['add'])){
if(isset($_POST['ajouterpodcastaudio'])){
$cat=$_POST['cat'];
$titre=addslashes($_POST['titre_podcasts']);
$date=addslashes($_POST['date_podcasts']);
$idalb=$_POST['catalb'];
$duree=$_POST['duree_podcasts'];
$numeropist=$_POST['numero_titre'];
$uploaddir = "../mp3/titre/";

$commaff= mysql_query("SELECT * FROM ".T_TITRE." ORDER BY id DESC");
$don = mysql_fetch_array($commaff);
$com=$don[0]+1;
$com=$com+500;
$mp3="son-$com.mp3";
$uploadfile = $uploaddir . $mp3;
move_uploaded_file($_FILES['mp3']['tmp_name'], $uploadfile);


$commaff= mysql_query("SELECT * FROM ".T_COMMENTAIRES." ORDER BY id_com DESC");
$don = mysql_fetch_array($commaff);
$com=$don[1]+1;
$modif = mysql_query("INSERT INTO ".T_COMMENTAIRES." VALUES('', '$com', '', '', '', '')");
$modif = mysql_query("INSERT INTO ".T_TITRE." VALUES('', '$titre', '$duree', '$date', '$mp3', '$idalb','$com','0','$numeropist')");
echo'<br/><div align="center">Titre Ajouter</div><br/>';
}
echo'<form action="admin_titre.php?add=1" method="post" enctype="multipart/form-data" name="form1" id="form1" onsubmit="return submitForm();">
';
$option= '<option value="0">Choix Artiste</option>';
$commaff= mysql_query("SELECT * FROM ".T_ARTISTES." ORDER BY nom");
while ($donnees = mysql_fetch_array($commaff))
{
$option.= '<option value="admin_titre.php?add=1&idart='.$donnees[0].'">'.$donnees[1].'</option>';
}
$option2='<option value="0">Choisissez un Artiste</option>';
if(isset($_GET['idart'])){
$option2="";
$art=$_GET['idart'];
$commaff= mysql_query("SELECT * FROM ".T_PODCAST." WHERE idcat='$art' ORDER BY titre");
while ($donnees = mysql_fetch_array($commaff))
{
$option2.= '<option value="'.$donnees[0].'">'.$donnees[1].'</option>';
}
$option= '';
$comm= mysql_query("SELECT * FROM ".T_ARTISTES." ORDER BY nom");
while ($don = mysql_fetch_array($comm))
{
$option.= '<option value="admin_titre.php?add=1&idart='.$don[0].'"';
if($don[0]==$art){

$option.=' selected="selected"';
}
$option.='>'.$don[1].'</option>';
}

}
echo'<table width="97%" height="200" border="0" cellspacing="0" cellpadding="0" class="main_table">
<tr>
<td height="45" colspan="2" class="t_header"><div align="center">Ajouter un Titre </div></td>
</tr>
<tr>
<td width="221" height="29" class="td_1"> Choix Artiste: </td>
<td width="414" class="td_2"><select name="cat" onchange="go(this)">
'.$option.'
</select></td>
</tr>
<tr>
<tr>
<td width="221" height="29" class="td_1"> Choix Album: </td>
<td width="414" class="td_2"><select name="catalb">
'.$option2.'
</select></td>
</tr>
<tr>
<td width="221" height="29" class="td_1"> Numero Titre:</td>
<td width="414" class="td_2"><input type="textfield" name="numero_titre" size="80" /></td>
</tr>
<tr>
<td width="221" height="29" class="td_1"> Nom du Titre:</td>
<td width="414" class="td_2"><input type="textfield" name="titre_podcasts" size="80" /></td>
</tr>
<tr>
<td width="221" height="29" class="td_1"> Durée:</td>
<td width="414" class="td_2"><input type="textfield" name="duree_podcasts" size="80" value="mm:ss" /></td>
</tr>
<tr>
<td width="221" height="29" class="td_1"> Date:</td>
<td width="414" class="td_2"><input type="textfield" name="date_podcasts" size="80" /></td>
</tr>
<tr>
<td width="221" height="29" class="td_1"> Mp3: </td>
<td width="414" class="td_2"><input type="file" name="mp3" size="80" /></td>
</tr>
<tr>
<td height="45" colspan="2" class="td_1" rowspan="2"><div align="center">
<input type="submit" name="ajouterpodcastaudio" value="Ajouter" class="button" />
</div></td>
</tr>
<tr>
<td rowspan="2"></td>
</tr>
</table>
</form>';
}
if(isset($_GET['mod'])){
$option="";
$commaff= mysql_query("SELECT * FROM ".T_PODCAST." ORDER BY titre");
while ($donnees = mysql_fetch_array($commaff))
{
$option.= '<option value="'.$donnees[0].'">'.$donnees[1].'</option>';
}
echo'<br/><div align="center">
';
echo'<table width="50%" height="26" border="0" cellpadding="0" cellspacing="0" align="center" class="main_table">
<tr>
<td height="45" colspan="3" class="t_header"><div align="center">Recherche Titre </div></td>
</tr>
<tr>
<td width="200" class="td_1" align="center"><form action="admin_titre.php" method="get" enctype="multipart/form-data" name="form1" id="form1"><input type="hidden" name="mod" value="1"/>Album: <select name="categorie" >
'.$option.'
</select> <input type="submit" value="Valider" class="button" /></form></td>
</tr>
<tr>
<td width="200" class="td_1" align="center"><form action="admin_titre.php" method="get" enctype="multipart/form-data" name="form1" id="form1">Titre Album: <input type="hidden" name="mod" value="1"/><input type="textfield" name="recherchetitre" size="30" /> <input type="submit" value="Recherche" class="button" /></form></td>
</tr></table>';
if(isset($_GET['supppodcast']))
{
$supprartiste=$_GET['supppodcast'];
$modif = mysql_query("DELETE FROM ".T_TITRE." WHERE id='$supprartiste'");
echo'<br/>Titre Supprimer';
}
if(isset($_GET['modpodcast']))
{
if(isset($_GET['modifier']))
{
$numeropodcast=$_GET['modpodcast'];
$cat=$_POST['cat'];
$titre=addslashes($_POST['titre_podcasts']);
$description=addslashes($_POST['titre_description']);
$date=addslashes($_POST['date_podcasts']);
$duree=addslashes($_POST['duree_podcasts']);
$numeropist=$_POST['numero_titre'];
if($_FILES['mp3']['error']!=4) {
$uploaddir = "../mp3/titre/";
$com=$numeropodcast+500;
$mp3="son-$com.mp3";
$uploadfile = $uploaddir . $mp3;
move_uploaded_file($_FILES['mp3']['tmp_name'], $uploadfile);
$modif=mysql_query("UPDATE ".T_TITRE." SET mp3='$mp3' WHERE id='$numeropodcast'");
}
$modif=mysql_query("UPDATE ".T_TITRE." SET titre='$titre', duree='$duree', date='$date', idalb='$cat', ordre='$numeropist' WHERE id='$numeropodcast'");
}
$numeropodcast=$_GET['modpodcast'];
$commaff= mysql_query( "SELECT * FROM ".T_TITRE." WHERE id='$numeropodcast'");
$donnees = mysql_fetch_array($commaff);
echo'<br/><form action="admin_titre.php?mod=1&modpodcast='.$donnees[0].'&modifier=1" method="post" enctype="multipart/form-data" name="form1" id="form1" onsubmit="return submitForm();">';
$option="";
$comm= mysql_query("SELECT * FROM ".T_PODCAST." ORDER BY titre");
while ($don = mysql_fetch_array($comm))
{
$option.= '<option value="'.$don[0].'"';
if($don[0]==$donnees[6]){

$option.=' selected="selected"';
}
$option.='>'.$don[1].'</option>';
}
echo'<table width="97%" height="200" border="0" cellspacing="0" cellpadding="0" class="main_table">
<tr>
<td height="45" colspan="2" class="t_header"><div align="center">Modifier un Titre </div></td>
</tr>
<tr>
<td width="221" height="29" class="td_1"> Choix Album: </td>
<td width="414" class="td_2"><select name="cat">
'.$option.'
</select></td>
</tr>
<tr>
<td width="221" height="29" class="td_1"> Numero Titre:</td>
<td width="414" class="td_2"><input type="textfield" name="numero_titre" size="80" value="'.$donnees[8].'" /></td>
</tr>
<tr>
<td width="221" height="29" class="td_1"> Titre:</td>
<td width="414" class="td_2"><input type="textfield" name="titre_podcasts" size="80" value="'.$donnees[1].'" /></td>
</tr>
<tr>
<td width="221" height="29" class="td_1"> Duré:</td>
<td width="414" class="td_2"><input type="textfield" name="duree_podcasts" size="80" value="'.$donnees[2].'" /></td>
</tr>
<tr>
<td width="221" height="29" class="td_1"> Date:</td>
<td width="414" class="td_2"><input type="textfield" name="date_podcasts" size="80" value="'.$donnees[3].'" /></td>
</tr>

<tr>
<td width="221" height="29" class="td_1"> mp3: </td>
<td width="414" class="td_2"><input type="file" name="mp3" size="80" /></td>
</tr>
<tr>
<td height="45" colspan="2" class="td_1"><div align="center">
<input type="submit" name="Modifierr" value="Modifier" class="button" />
</div></td>
</tr>
</table>
</form>';
}
$go=0;
if(isset($_GET['recherchetitre'])){
$recherche=$_GET['recherchetitre'];
$total=0;
$totalid= mysql_query("SELECT * from ".T_TITRE." where titre LIKE '%$recherche%'");
while ($donnees = mysql_fetch_array($totalid))
{
$total++;
}
$parpage=8;
if(isset($_GET['page']))
$page=$_GET['page'];
else
$page=0;
$go=1;
echo'<br/><table width="97%" border="0" cellspacing="0" class="main_table">';
$commaff= mysql_query("SELECT * from ".T_TITRE." where titre LIKE '%$recherche%' LIMIT $page,$parpage");
}
if(isset($_GET['categorie'])){
$id_cat=$_GET['categorie'];
$total=0;
$totalid= mysql_query("SELECT * from ".T_TITRE." where idalb='$id_cat'");
while ($donnees = mysql_fetch_array($totalid))
{
$total++;
}
$parpage=8;
if(isset($_GET['page']))
$page=$_GET['page'];
else
$page=0;

echo'<br/><table width="97%" border="0" cellspacing="0" class="main_table">';
$commaff= mysql_query("SELECT * from ".T_TITRE." where idalb='$id_cat' LIMIT $page,$parpage");
$go=1;
}
if($go==1){
while ($donnees = mysql_fetch_array($commaff))
{

echo'<tr>
<td width="193" class="td_1">'.$donnees[1].'</td>
<td width="68" class="td_1" align="center"><form action="admin_titre.php?mod=1&modpodcast='.$donnees[0].'" method="post"><input type="submit" value="Modifier" class="button" />
</form></td>
<td width="81" class="td_1" align="center"><form action="admin_titre.php?mod=1&supppodcast='.$donnees[0].'" method="post">
<input name="button" type="submit" value="Supprimer" class="button" />
</form></td>
</tr>';
}
echo'</table></div>';
echo'<br/><div align="center">';
for($i=0;$i<=ceil($total/$parpage)-1;$i++)
{
$nbre=$i*$parpage;
$numeropage=$i+1;
if($page==$nbre){
echo$numeropage;
}else{
echo'<a href="admin_titre.php?mod=1&recherchetitre='.$recherche.'&lettre='.$lettre.'&page='.$nbre.'">'.$numeropage.'</a>';
}
echo' -';
}
echo"</div>";
}
}
}else{
include("erreur.php");
}

?>

1 réponse

pas de réponse ???
aidez moi svp ??????????
0