title: php redirection that won't redirect
body: <p>I'm making a redirection thanks to PHP but it doesn't redirect at all (but make everithing else that redirecting).</p>
  
  <p>here's the code that I've implemented:</p>
  
  <pre><code>&lt;?php 
  session_start();    // pour pouvoir récupérer /creer desvariables de session
  
  try
  {
      $bdd = new PDO('mysql:host=localhost;dbname=youf', 'root', 'root');
  }
  catch(Exception $e)
  {
          die('Erreur : '.$e-&gt;getMessage());
  }
  
  $redirection="command.php";
  if (!isset($_SESSION['Login'])){ header('Location: connect.php'); } // Si pas de sessionactives, redirect
      if (!isset($_SESSION['CommandId'])){
          $long = strlen($_SESSION['Login']);
          $table = $_SESSION['Login'][$long-2].$_SESSION['Login'][$long-1];
          $zone = $_SESSION['Login'][$long-4].$_SESSION['Login'][$long-3];
          $createCommand="INSERT INTO `youfood`.`command` (`Number`, `Date`, `isPaid`, `Table`, `Zone`, `Server`, `State`) VALUES (NULL, current_date, '0', '".$table."', '".$zone."', '".$_SESSION['NumberEmployee']."', '5');";
          $bdd-&gt;query($createCommand);
  
          $sqlCommandNumber=$bdd-&gt;query("SELECT * FROM  `command` WHERE  `Table` =".$table." AND  `Zone` =".$zone." AND  `State` =0 LIMIT 0 , 1");
          $commandNumber="";
          while ($data=$sqlCommandNumber-&gt;fetch()){
              $commandNumber = $data['Number'];
          }
          $_SESSION['CommandId'] = $commandNumber ;
          header('Location: actionValidateCommand.php');
          $redirection="actionValidatedCommand.php";
      } else {
          foreach ( $_SESSION['cart'] as $key =&gt; $value ) {
              if($value != 0){
                  $sql = "INSERT INTO  `youfood`.`commanddishe` (`Number` ,`command` ,`Dishe` ,`Quantity`)VALUES (NULL, '".$_SESSION['CommandId']."', '".$key."', '".$value."')";
                  $bdd-&gt;query($sql);
                  $messagee = $messagee."&lt;br /&gt;".$sql."&lt;br /&gt;";
                  $_SESSION['cart'][$key] = 0 ;
              }
          }
      header('Location: command.php');
      $redirection="command.php";
  }
  ?&gt;
  &lt;!DOCTYPE html&gt; 
  &lt;html&gt; 
  </code></pre>
  
  <p>And when I inspect the html result of the page that doesn't redirect, I see a space before the  tag. I don't know where the space is made and I know that it's the mistake!</p>
  
  <p>Thanks to help me :-)</p>