BobDan
Invité n'ayant pas de compte PHPfrance
10 avr. 2006, 15:53
Je suis désolé, j'ai cherché pour les valeurs de retour mais je n'y arrive pas... j'ai tout essayé avec 0,1,true, false, !$variable....tout..
en fait, je n'arrive pas à afficher le $content différent si l'enregistrement est bon ou s'il est mauvais, il me laisse tout le temps le formulaire à l'affichage.
Désolé mais le code est long....
<?php
require_once('../includes/params.php');
require_once('../includes/functions.php');
// Variable de la page
$page = "backoffice/".basename($_SERVER['PHP_SELF']);
$infos = pageInfos($page,$connect);
$title = $infos['title'];
// Taille max des fichiers (octets)
$MFS=120000;
// Module de sécurité
include('../includes/auth.php');
//menu de la page
$top_level = substr($infos['menu_lev'],0,2);
$menu = leftMenu($top_level,3,$infos['menu_side'],$infos['menu_type'],$connect);
if (isLogin()) {
// Répertoire de stockage
$rep="../medias/images/clients/";
if(isset($_FILES['userfile'])) {
$savefile= $rep.$_FILES['userfile']['name'];
$temp = $_FILES['userfile']['tmp_name'];
if (move_uploaded_file($temp, $savefile)) { ?>
<b>Votre fichier a bien été enregistré !</b>
<BR>Nom : <? echo $_FILES['userfile']['name']; ?>
<BR>Taille : <? echo $_FILES['userfile']['size']; ?>
<BR>Type : <? echo $_FILES['userfile']['type']; ?>
<?
$query= sprintf("INSERT INTO customer VALUES('24','".$_POST['Nom']."', '".$_POST['Texte']."', 'clients/".$_FILES['userfile']['name']."', 'javascript:popup_customers(\"popup/popupclient".$_POST['Nom'].".php\")', '".$_POST['Type']."')");
// Exécution de la requête
$test = mysql_query($query);
if(!$test)
{
$content = "<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr><td><h1>" . $infos['menu_name'] . "</h1></td></tr>
<tr><td heigth='10'> </td></tr>
<tr><td align='center'>
<table width='90%' border='0' cellspacing='0' cellpadding='0' align='center'>
<tr><td align='center'><font class='red'>!!!! Erreur d'ajout de l'événement " . $_POST['Nom'] . " !!!</font></td></tr>
<tr><td align='right'>
<a href='" . $_SERVER['PHP_SELF'] . "'>
<img src='" . DIR_IMAGES . "puces/puce_top.gif' border='0' align='absmiddle'></a>
<a href='" . $_SERVER['PHP_SELF'] . "' class='bluelink'> Retour</a>
</td></tr>
</table>
<tr><td heigth='20'> </td></tr>
</table>";
}
else
{
$content = "<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr><td><h1>" . $infos['menu_name'] . "</h1></td></tr>
<tr><td heigth='10'> </td></tr>
<tr><td align='center'>
<table width='90%' border='0' cellspacing='0' cellpadding='0' align='center'>
<tr><td align='center'>Le client " . $_POST['Nom'] . " a été ajouté.</td></tr>
<tr><td align='right'>
<a href='" . $_SERVER['PHP_SELF'] . "'>
<img src='" . DIR_IMAGES . "puces/puce_top.gif' border='0' align='absmiddle'></a>
<a href='" . $_SERVER['PHP_SELF'] . "' class='bluelink'> Retour</a>
</td></tr>
</table>
<tr><td heigth='20'> </td></tr>
</table>";
}
?>
<?
} else { ?>
<b>Trop gros fichier !</b>
<i>( <? echo $MFS;?> octets max.)</i>
<i>(<? echo $_FILES['fichier_source']['error'] ?>)</ i>
<? }
}
$yes_no_select_array = array(array('val'=>'0','name'=>'Non'),array('val'=>'1','name'=>'Oui'));
// Selection de la base de données
$select_db = mysql_select_db(DATABASE, $connect) or die(SELECT_ERROR);
// Création de la requète
$query = "SELECT * FROM " . INDUSTRY_TABLE . ";";
// Exécution de la requéte
$result = mysql_query($query,$connect);
$ind_id_array=array();
while ($rows=mysql_fetch_object($result)){
$ind_id_array = array_merge($ind_id_array,array(array('val'=>$rows->ind_id,'name'=>$rows->ind_name)));
}
$form_array = array(array('type'=>'hidden','name'=>'treatment','label'=>'','value'=>'1','required'=>'','valided'=>'','specific'=>''),
array('type'=>'select','name'=>'Type','label'=>'Catégorie du client','value'=>$ind_id_array,'required'=>'1','valided'=>'R','specific'=>''),
array('type'=>'text','name'=>'Nom','label'=>'Nom','value'=>'','required'=>'1','valided'=>'R','specific'=>''),
array('type'=>'textarea','name'=>'Texte','label'=>'Texte du client','value'=>'','required'=>'0','valided'=>'','specific'=>'3'),
array('type'=>'image','name'=>'Lien_Image','label'=>'Image','value'=>'','required'=>'','valided'=>'','specific'=>'3'),
array('type'=>'textarea','name'=>'Cible_URL','label'=>'Cible lien du PopUp','value'=>'','required'=>'','valided'=>'','specific'=>'3'),
);
$content = "<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr><td><h1>" . $infos['menu_name'] . "</h1></td></tr>
<tr><td heigth='10'> </td></tr>
<tr><td align='center'>
<table width='90%' border='0' cellspacing='0' cellpadding='0' align='center'>
<tr><td>" . form_generation_add_clients('add_clients','Ajouter',$_SERVER['PHP_SELF'],'fr',$form_array) . "</td></tr>
<tr><td height='10'></td></tr>
<tr><td align='right'>
<a href='" . $_SERVER['PHP_SELF'] . "'>
<img src='" . DIR_IMAGES . "puces/puce_top.gif' border='0' align='absmiddle'></a>
<a href='" . $_SERVER['PHP_SELF'] . "' class='bluelink'> Retour</a>
</td></tr>
</table>
</table>";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Typ!" content="text/html; charset=iso-8859-1">
<meta http-equiv="description" content="Accueil Back Office du Site Dassault Sytèmes Vente Solutions France">
<meta http-equiv="keywords" content="Dassault Systèmes solutions vente france catia delmia smarteam svp plm">
<!-- Appel de la feuille de style global.css -->
<link rel="stylesheet" type="text/css" href="../css/agt.css">
<!-- Appel des fonctions javascript contenu dans global.js -->
<script language="javascript" src="../js/global.js"></script>
<title>Dassault Systèmes - <? echo $title;?></title>
</head>
<body>
<? include("../includes/topnav_back.php"); ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="bckgddeg">
<tr><td>
<table width="780" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="162" valign="top" class="bordergrey_lrb deg2" rowspan="3"><? echo $menu; ?></td>
<td width="618" height="74" valign="top" class="bordergrey_r"><? include("../includes/headers.php"); ?></td>
</tr>
<tr>
<td width="618" valign="top" class="bordergrey_r deg2"><? echo $content; ?>
</td>
</tr><tr>
<td colspan="2" height="55" class="bordergrey_rb" valign="bottom"><? include("../includes/footer.php"); ?></td>
</tr>
</table>
</td></tr>
</tr><td height="400"> </td></tr>
</table>
</body>
</html>
Merci à vous pour votre aide