0) { mysql_free_result($rsQuery); $exist=1; } $CoutM=($_POST["Unite"])*($_POST["Cout"]); $_SESSION["NomEquipement"]= ($_POST["Nom"]); $_SESSION["DescriptionEquipement"]= ($_POST["Description"]); $_SESSION["TypeUtilisation"]= ($_POST["TypeUtilisation"]); $_SESSION["StatutEquipement"]= ($_POST["Statut"]); $_SESSION["Unite"]= ($_POST["Unite"]); $_SESSION["CoutEquipement"]= ($_POST["Cout"]); $_SESSION["CoutMEquipement"]= $CoutM; //'**********recuperer les valeurs****** $SQLcha = $SQLcha." Nom , "; $SQLval = $SQLval."'".$_POST["Nom"]."' , "; $SQLcha = $SQLcha." Description , "; $SQLval = $SQLval."'".($_POST["Description"])."' , "; $SQLcha = $SQLcha." TypeUtilisation , "; $SQLval = $SQLval."'".($_POST["TypeUtilisation"]). "' , "; $SQLcha = $SQLcha." Unite , "; $SQLval = $SQLval."'".($_POST["Unite"])."' , "; $SQLcha = $SQLcha." Statut , "; $SQLval = $SQLval."'".$_POST["Statut"]."' , "; $SQLcha = $SQLcha." Cout , "; $SQLval = $SQLval."'".($_POST["Cout"])."' , "; $SQLcha = $SQLcha." CoutM , "; $SQLval = $SQLval."'".$CoutM."' , "; $SQLcha = $SQLcha." DateAjouter , "; $SQLval = $SQLval."'".date('y-m-j h:i:s')."' , "; /******************Insertion de l'image*******************************/ if (!empty($_FILES['doc_file']['name'])) { $target_path = $target_path.( $_FILES["doc_file"]['name']); if (ereg("\.([^.]+)$", $_FILES['doc_file']['name'], $match)) { $ext = strtolower($match[1]); } //$_FILES["doc_file"]['tmp_name']; // This is how we will get the temporary file... if ($ext!='jpg' and $ext!='png'and $ext!='gif') { $exist=3; }else { if(!move_uploaded_file($_FILES["doc_file"]['tmp_name'], $target_path)) $exist=4; else { $SQLcha = $SQLcha." picture , "; $SQLval = $SQLval."'".($_FILES["doc_file"]['name'])."' , "; } } } /**************************************************************************/ if ((isset($_POST["Nom"]))&&(empty($_POST["Nom"]))) $exist=2; if ($exist!=0) Header("Location:AjouterEquipement.php?exist=".$exist.""); //'*********verification si le nom existe ou pas $strSql = "SELECT CodeE from equipements where Nom = '".($_POST["Nom"])."' "; $rsQuery = mysql_query($strSql); if ($row = mysql_fetch_assoc($rsQuery)) { $CodeE = $row["CodeE"]; mysql_free_result($rsQuery); Header("Location:UpdateEquipement.php?CodeE=".$CodeE.""); } //'*********SQL Insert*************** if ($exist==0) { $Sql="Insert into equipements (". substr($SQLcha, 0, strlen($SQLcha) - 2).") VALUES (". substr($SQLval, 0,strlen($SQLval) - 2).")"; echo $Sql; mysql_query($Sql) or die('Error, insert query failed'). mysql_error(); } //'********************************** //'*********recuperer le code de personne ******** $strSql = "SELECT CodeE from equipements where (Nom = '".($_POST["Nom"])."')"; $rsQuery = mysql_query($strSql); if ($row = mysql_fetch_assoc($rsQuery)) { $CodeE = $row["CodeE"]; } mysql_free_result($rsQuery); Header("Location:RechercheEquipement.php?CodeE=".$CodeE.""); ?>