Bonjour,

Je sais que beaucoup de messages sont postés sur le sujet (j'en ai déjà lus pas mal, sans pour autant réussir à solutionner mon problème).

Quand un nouveau client s'inscrit sur mon site, la validation du formulaire enregistre correctement toutes les données dans la base par contre, au lieu d'ouvrir la page vers laquelle il devrait être redirigé, le client se retrouve devant le formulaire d'inscription (vide) qu'il vient de remplir et il y a l'erreur suivante qui s'affiche :
Warning: Cannot modify header information - headers already sent by (output started at /wxxx/inscription.php:5) in /xxx/inscription.php on line 83

Voici la ligne 83 :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
header(sprintf("Location: %s", $insertGoTo));
J'utilise cette ligne de code dans d'autres fichiers (ex : ajout fiche produit) et ça fonctionne. Je n'arrive pas à voir la différence...

Voici tout ce qui se trouve avant mon doctype :
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
<?php 
session_start(); 
?>

<?php require_once('../Connections/xxx.php'); ?>
<?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;
}
}

// Redirect if username exists
$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
  $MM_dupKeyRedirect="inscription.php";
  $loginUsername = $_POST['mail'];
  $LoginRS__query = sprintf("SELECT mail FROM client WHERE mail=%s", GetSQLValueString($loginUsername, "text"));
  mysql_select_db($database_xxx, $xxx);
  $LoginRS=mysql_query($LoginRS__query, $xxx) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);

  //if there is a row in the database, the username was found - can not add the requested username
  if($loginFoundUser){
    $MM_qsChar = "?";
    //append the username to the redirect page
    if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&";
    $MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
    header ("Location: $MM_dupKeyRedirect");
    exit;
  }
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "client")) {
  $insertSQL = sprintf("INSERT INTO client (nom, prenom, mot_passe, adresse1, cp, ville, mail, tel) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['nom'], "text"),
                       GetSQLValueString($_POST['prenom'], "text"),
                       GetSQLValueString($_POST['mot_passe'], "text"),
                       GetSQLValueString($_POST['adresse1'], "text"),
                       GetSQLValueString($_POST['cp'], "int"),
                       GetSQLValueString($_POST['ville'], "text"),
                       GetSQLValueString($_POST['mail'], "text"),
                       GetSQLValueString($_POST['tel'], "text"));

  mysql_select_db($database_xxx, $xxx);
  $Result1 = mysql_query($insertSQL, $xxx) or die(mysql_error());

  $insertGoTo = "inscription_conf.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
 
}
?>
J'espère que quelqu'un pourra m'expliquer comment pallier cette erreur.