bonsoir, je suis embarrassé!

j'ai développé un système de gestion des base de données de voitures d'occasions qui fonctionne parfaitement dans tous les cas en local mais depuis que j'ai rajouté un contrôle d'utilisateur, ça ne marche plus sur le site distant.

Pour la saisie des voitures, j'ai découpé l'opération en deux pages, la première reçoit les paramètres "textes" et la seconde page gère les images. Ainsi les pages sont plus faciles à lire. Donc, à la soumission du 1er formulaire, j'ouvre la 2eme page où je sélectionne le dernier enregistrement créé par une requête et je propose la saisie des image par un formulaire pour cet enregistrement.
J'utilise les fonctions PHP de DW CS4.

Depuis que j'ai rajouté le contrôle d'utilisateur, et la fonction log-out, ça ne marche plus sur le site distant, j'ai l'erreur suivante:

Warning: Cannot modify header information -
headers already sent by (output started at /htdocs/public/www/carbase/admin/cb_new_car1.php:76)
in /htdocs/public/www/carbase/admin/cb_new_car1.php on line 190


Je répète que touta fonctionne tout le temps parfaitement en local....

Je vois pas d'où ça peut venir

Je joins le code de la page (un peu long , je sais , désolé.... :-)

merci


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
<?php require_once('../Connections/connGarage.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}
 
// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}
 
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
  $_SESSION['MM_Username'] = NULL;
  $_SESSION['MM_UserGroup'] = NULL;
  $_SESSION['PrevUrl'] = NULL;
  unset($_SESSION['MM_Username']);
  unset($_SESSION['MM_UserGroup']);
  unset($_SESSION['PrevUrl']);
 
  $logoutGoTo = "index.php";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
 
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 
 
  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}
 
$MM_restrictGoTo = "cb_echec.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) 
  $MM_referrer .= "?" . $QUERY_STRING;
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
 
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }
 
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
 
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
 
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
 
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
// traitement des erreurs
$error = array();
$_POST['modele'] = trim($_POST['modele']);
//$_POST['options'] = trim($_POST['options']);
$_POST['annee'] = trim($_POST['annee']);
//$_POST['mois'] = trim($_POST['mois']);
$_POST['km'] = trim($_POST['km']);
$_POST['couleur'] = trim($_POST['couleur']);
$_POST['cvfiscaux'] = trim($_POST['cvfiscaux']);
$_POST['prix'] = trim($_POST['prix']);
//$_POST['financement'] = trim($_POST['financement']);
//$_POST['garantie'] = trim($_POST['garantie']);
 
 
if (empty($_POST['modele']))	{
		$error['modele'] = 'Le modèle n\'a pas été saisi';
		}
/*if (empty($_POST['options']))	{
		$error['options'] = 'Les options n\'ont pas été saisies';
		}*/
if (empty($_POST['annee']))	{
		$error['annee'] = 'L\'année n\'a pas été saisie';
		}
/*if (empty($_POST['mois']))	{
		$error['mois'] = 'Le mois n\'a pas été saisie';
		}*/
if (empty($_POST['km']))	{
		$error['km'] = 'Le kilométrage n\'a pas été saisi';
		}
if (empty($_POST['couleur']))	{
		$error['couleur'] = 'La couleur n\'a pas été saisie';
		}
if (empty($_POST['cvfiscaux']))	{
		$error['cvfiscaux'] = 'La puissance n\'a pas été saisie';
		}
if (empty($_POST['prix']))	{
		$error['prix'] = 'Le prix n\'a pas été saisi';
		}
/*if (empty($_POST['financement']))	{
		$error['financement'] = 'Le financement n\'a pas été saisi';
		}
if (empty($_POST['garantie']))	{
		$error['garantie'] = 'La garantie n\'a pas été saisi';
		}*/
 
// si pas d'erreurs
if (!$error)	{
  $insertSQL = sprintf("INSERT INTO vehicules (constructorID, modele, options, annee, mois, km, couleur, cvfiscaux, prix, dispo, photo1, photo2, photo3, photo4, photo5, financement, garantie, observations) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['constructorID'], "text"),
                       GetSQLValueString(utf8_decode($_POST['modele']), "text"),
                       GetSQLValueString(utf8_decode($_POST['options']), "text"),
                       GetSQLValueString($_POST['annee'], "date"),
                       GetSQLValueString($_POST['mois'], "int"),
                       GetSQLValueString($_POST['km'], "int"),
                       GetSQLValueString(utf8_decode($_POST['couleur']), "text"),
                       GetSQLValueString($_POST['cvfiscaux'], "int"),
                       GetSQLValueString($_POST['prix'], "int"),
                       GetSQLValueString($_POST['dispo'], "text"),
                       GetSQLValueString('../images/generique.jpg', "text"),
                       GetSQLValueString('../images/generique.jpg', "text"),
                       GetSQLValueString('../images/generique.jpg', "text"),
                       GetSQLValueString('../images/generique.jpg', "text"),
                       GetSQLValueString('../images/generique.jpg', "text"),
                       GetSQLValueString(utf8_decode($_POST['financement']), "text"),
                       GetSQLValueString($_POST['garantie'], "int"),
                       GetSQLValueString(utf8_decode($_POST['observations']), "text"));
 
  mysql_select_db($database_connGarage, $connGarage);
  $Result1 = mysql_query($insertSQL, $connGarage) or die(mysql_error());
 
 
  $insertGoTo = "cb_new_car2.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
}	// fin trt erreur
 
/*mysql_select_db($database_connGarage, $connGarage);
$query_rsAddCar = "SELECT * FROM vehicules";
$rsAddCar = mysql_query($query_rsAddCar, $connGarage) or die(mysql_error());
$row_rsAddCar = mysql_fetch_assoc($rsAddCar);
$totalRows_rsAddCar = mysql_num_rows($rsAddCar);*/
 
mysql_select_db($database_connGarage, $connGarage);
$query_rsConstructor = "SELECT * FROM `constructor` ORDER BY marque";
$rsConstructor = mysql_query($query_rsConstructor, $connGarage) or die(mysql_error());
$row_rsConstructor = mysql_fetch_assoc($rsConstructor);
$totalRows_rsConstructor = mysql_num_rows($rsConstructor);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Saisir un nouveau v&eacute;hicule</title>
<link href="../css/base.css" rel="stylesheet" type="text/css" />
</head>
 
<body>
<div id="wrapper">
<div id="sidebar">
  <img src="../imagesweb/logo2.jpg" width="230" height="250" />
<div id="menuLateral">
<p>Utilisateur : <?php echo $_SESSION['MM_Username']; ?></p>
<ul id="menu2">
  <li><a href="<?php echo $logoutAction ?>">Log out</a></li>
  <li><a href="cb_admin.php">Annuler l'op&eacute;ration</a></li>
</ul>
</div><!-- fin du menuLateral  -->  
 
 
 
 
  </div>	
<!-- fin sidebar  -->
<div id="content">
<h2>S.AISIR UN NOUVEAU V&Eacute;HICULE</h2>
<p>(&Eacute;tape 1)</p>
<?php 
if (isset($error))	{
	echo '<ul class="errorSaisie">';
	foreach ($error as $alert) {
		echo "<li class='warning'>$alert</li>\n";
		}
	echo '</ul>';
	}
?>
  <form action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
    <table align="center" cellspacing="0">
      <tr class="trOdd" valign="baseline">
        <td width="100" align="right" nowrap="nowrap">Marque :</td>
        <td width="320"><select name="constructorID">
          <?php 
do {  
?>
          <option value="<?php echo $row_rsConstructor['ID']?>" <?php if (!(strcmp($row_rsConstructor['ID'], 1))) {echo "SELECTED";} ?>><?php echo utf8_encode($row_rsConstructor['marque'])?></option>
          <?php
} while ($row_rsConstructor = mysql_fetch_assoc($rsConstructor));
?>
        </select></td>
        <td width="130">&nbsp;</td>
      </tr>
      <tr valign="baseline" class="trEven">
        <td nowrap="nowrap" align="right">Modèle:</td>
        <td><input type="text" name="modele" value="<?php if (isset($_POST['modele']))  {
echo htmlentities($_POST['modele'], ENT_COMPAT, 'UTF-8');} ?>" size="45" /></td>
        <td><?php
      if (isset($error['modele'])) { ?>
      <span class="warning">Champ obligatoire</span><?php } ?></td>
      </tr>
      <tr valign="baseline" class="trOdd">
        <td nowrap="nowrap" align="right">Options:</td>
        <td>
      <input type="text" name="options" value="<?php if (isset($_POST['options']))  {
echo htmlentities($_POST['options'], ENT_COMPAT, 'UTF-8');} ?>" size="45" /></td>
        <td>&nbsp;</td>
      </tr>
      <tr valign="baseline" class="trEven">
        <td nowrap="nowrap" align="right">Année (AAAA):</td>
        <td>
      <input type="text" name="annee" value="<?php if (isset($_POST['annee']))  {
echo htmlentities($_POST['annee'], ENT_COMPAT, 'UTF-8');} ?>" size="45" /></td>
        <td><?php
      if (isset($error['annee'])) { ?>
      <span class="warning">Champ obligatoire</span><?php } ?></td>
      </tr>
 
 
<tr valign="baseline" class="trOdd">
  <td nowrap="nowrap" align="right"><br />Mois:</td>
  <td valign="baseline">
 
    <table class="selectMois">
      <tr>
        <td><input type="radio" name="mois" value="1" <?php if (isset($_POST['mois']) && $_POST['mois'] ==  1) { echo 'checked="checked"'; }  ?> />
          Janvier</td>
 
        <td><input type="radio" name="mois" value="2" <?php if (isset($_POST['mois']) && $_POST['mois'] ==  2) { echo 'checked="checked"'; }  ?> />
          Février</td>
 
        <td><input type="radio" name="mois" value="3" <?php if (isset($_POST['mois']) && $_POST['mois'] ==  3) { echo 'checked="checked"'; }  ?> />
          mars</td>
        </tr>
      <tr>
        <td><input type="radio" name="mois" value="4" <?php if (isset($_POST['mois']) && $_POST['mois'] ==  4) { echo 'checked="checked"'; }  ?> />
          Avril</td>
 
        <td><input type="radio" name="mois" value="5" <?php if (isset($_POST['mois']) && $_POST['mois'] ==  5) { echo 'checked="checked"'; }  ?> />
          Mai</td>
 
        <td><input type="radio" name="mois" value="6" <?php if (isset($_POST['mois']) && $_POST['mois'] ==  6) { echo 'checked="checked"'; }  ?> />
          Juin</td>
        </tr>
      <tr>
        <td><input type="radio" name="mois" value="7" <?php if (isset($_POST['mois']) && $_POST['mois'] ==  7) { echo 'checked="checked"'; }  ?> />
          Juillet</td>
 
        <td><input type="radio" name="mois" value="8" <?php if (isset($_POST['mois']) && $_POST['mois'] ==  8) { echo 'checked="checked"'; }  ?> />
          Aout</td>
 
        <td><input type="radio" name="mois" value="9" <?php if (isset($_POST['mois']) && $_POST['mois'] ==  9) { echo 'checked="checked"'; }  ?> />
          Septembre</td>
        </tr>
      <tr>
        <td><input type="radio" name="mois" value="10" <?php if (isset($_POST['mois']) && $_POST['mois'] ==  10) { echo 'checked="checked"'; }  ?> />
          Octobre</td>
 
        <td><input type="radio" name="mois" value="11" <?php if (isset($_POST['mois']) && $_POST['mois'] ==  11) { echo 'checked="checked"'; }  ?> />
          Novembre</td>
 
        <td><input type="radio" name="mois" value="12" <?php if (isset($_POST['mois']) && $_POST['mois'] ==  12) { echo 'checked="checked"'; }  ?> />
          D&eacute;cembre</td>
        </tr>
      </table>
    </td>
    <td></td>
</tr>      
 
 
 
 
 
 
 
 
 
      <tr valign="baseline" class="trEven">
        <td nowrap="nowrap" align="right">Km:</td>
        <td><input type="text" name="km" value="<?php if (isset($_POST['km']))  {
echo htmlentities($_POST['km'], ENT_COMPAT, 'UTF-8');} ?>" size="45" /></td>
        <td><?php
      if (isset($error['km'])) { ?>
      <span class="warning">Champ obligatoire</span><?php } ?></td>
      </tr>
      <tr valign="baseline" class="trOdd">
        <td nowrap="nowrap" align="right">Couleur:</td>
        <td><input type="text" name="couleur" value="<?php if (isset($_POST['couleur']))  {
echo htmlentities($_POST['couleur'], ENT_COMPAT, 'UTF-8');} ?>" size="45" /></td>
        <td><?php
      if (isset($error['couleur'])) { ?>
      <span class="warning">Champ obligatoire</span><?php } ?></td>
      </tr>
      <tr valign="baseline" class="trEven">
        <td nowrap="nowrap" align="right">Puissance (XX):</td>
        <td><input type="text" name="cvfiscaux" value="<?php if (isset($_POST['cvfiscaux']))  {
echo htmlentities($_POST['cvfiscaux'], ENT_COMPAT, 'UTF-8');} ?>" size="45" /></td>
        <td><?php
      if (isset($error['cvfiscaux'])) { ?>
      <span class="warning">Champ obligatoire</span><?php } ?></td>
      </tr>
      <tr valign="baseline" class="trOdd">
        <td nowrap="nowrap" align="right">Prix:</td>
        <td><input type="text" name="prix" value="<?php if (isset($_POST['prix']))  {
echo htmlentities($_POST['prix'], ENT_COMPAT, 'UTF-8');} ?>" size="45" /></td>
        <td><?php
      if (isset($error['prix'])) { ?>
      <span class="warning">Champ obligatoire</span><?php } ?></td>
      </tr>
 
 
      <tr valign="baseline" class="trEven">
        <td nowrap="nowrap" align="right">Dispo &agrave; la vente:</td>
        <td valign="baseline">
        <table>
          <tr>
       <?php   if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { ?>  <!-- permet d'initialiser le 1er bouton radio  -->
            <td><input type="radio" name="dispo" value="o" <?php if (isset($_POST['dispo']) && $_POST['dispo'] ==  "o") { echo 'checked="checked"'; } ?> />
              Dispo</td> <?php } else { ?>
            <td><input type="radio" name="dispo" value="o" checked="checked" />Dispo</td>  <?php }  ?> <!-- fin init 1er bouton  -->  
            <td><input type="radio" name="dispo" value="n" <?php if (isset($_POST['dispo']) && $_POST['dispo'] ==  "n") { echo 'checked="checked"'; } ?> />
              Pas Dispo</td>
 
            </tr>
          </table>
          </td>
        <td valign="baseline">&nbsp;</td>
      </tr>
 
<!-- Financement  -->     
      <tr valign="baseline" class="trOdd">
        <td nowrap="nowrap" align="right">Financement:</td>
        <td><input type="text" name="financement" value="<?php if (isset($_POST['financement']))  {
echo htmlentities($_POST['financement'], ENT_COMPAT, 'UTF-8');} ?>" size="45" /></td>
        <td>mention</td>
      </tr>
 
<!-- Garantie -->      
      <tr valign="baseline" class="trEven">
        <td nowrap="nowrap" align="right">Garantie:</td>
        <td>
 
        <table>
          <tr>
       <?php   if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { ?>  <!-- permet d'initialiser le 1er bouton radio  -->
 
            <td><input type="radio" name="garantie" value="3" <?php if (isset($_POST['garantie']) && $_POST['garantie'] ==  3) { echo 'checked="checked"'; } ?> />
              3mois</td>  <?php } else { ?>
            <td><input type="radio" name="garantie" value= "3" checked="checked" />3 mois</td> <?php } ?> <!-- fin init 1er bouton  --> 
 
            <td><input type="radio" name="garantie" value="6" <?php if (isset($_POST['garantie']) && $_POST['garantie'] ==  6) { echo 'checked="checked"'; }  ?> />
              6 mois</td>
            <td><input type="radio" name="garantie" value="12"  <?php if (isset($_POST['garantie']) && $_POST['garantie'] ==  12) { echo 'checked="checked"'; }  ?> />
              12 mois</td>
            <td><input type="radio" name="garantie" value="99"  <?php if (isset($_POST['garantie']) && $_POST['garantie'] ==  99) { echo 'checked="checked"'; }  ?> />
              nous consulter</td>
            </tr>
          </table>
 
 
 
       <!-- <input type="text" name="garantie" value="<?php /*if (isset($_POST['garantie']))  {
echo htmlentities($_POST['garantie'], ENT_COMPAT, 'UTF-8');}*/ ?>" size="45" />
-->
 
 
</td>
        <td><?php
      if (isset($error['garantie'])) { ?>
      <span class="warning">Champ obligatoire</span><?php } ?></td>
      </tr>
 
 
 
<!-- Observations -->      
      <tr valign="baseline" class="trOdd">
        <td nowrap="nowrap" align="right">Observations:</td>
        <td colspan="2"><textarea name="observations" cols="45" rows="10" ><?php if (isset($_POST['observations']))  {echo htmlentities($_POST['observations'], ENT_COMPAT, 'UTF-8');} ?>
        </textarea></td>
        </tr>
      <tr valign="baseline" class="trEven">
        <td nowrap="nowrap" align="right">&nbsp;</td>
        <td><input type="submit" value="... Suite" /></td>
        <td>&nbsp;</td>
      </tr>
    </table>
    <input type="hidden" name="MM_insert" value="form1" />
  </form>
  <p>&nbsp;</p>
</div>	
<!-- fin du content -->
<div id="footer">
</div>	<!-- fin du footer -->
</div>	
<!-- fin wrapper  -->
</body>
</html>
<?php
//mysql_free_result($rsAddCar);
 
mysql_free_result($rsConstructor);
?>