title: How to redirect in PHP?
body: <p>Searched the web for the past hour and none of the solutions worked for me.</p>
  
  <p>Both my signUp or login functions don't redirect.</p>
  
  <p>I'm not doing any echo's before I set my header.</p>
  
  <p>My current code:</p>
  
  <pre><code>&lt;?php
      require_once($_SERVER["DOCUMENT_ROOT"].'/Model/User/UserDto.php');
      require_once($_SERVER["DOCUMENT_ROOT"].'/Model/FacadeFactory.php');
  
      $action = $_GET['action'];
      $action();
  
      function signUp() {
          $email = $_POST['email'];
          $password = $_POST['password'];
  
          $userDto = new UserDto($email, $password);
          FacadeFactory::getDomainFacade()-&gt;signUp($userDto);
          FacadeFactory::getDomainFacade()-&gt;login($userDto);
  
  
          $location = sprintf("Location: %s%s",$_SERVER["HTTP_HOST"], "/View/Dashboard");
          header($location);
          exit();
      }
  
      function login() {
          $email = $_POST['email'];
          $password = $_POST['password'];
  
          $userDto = new UserDto($email, $password);
          FacadeFactory::getDomainFacade()-&gt;login($userDto);
  
          $location = sprintf("Location: %s%s",$_SERVER["HTTP_HOST"], "/View/Dashboard");
          ob_start();
          header($location);
          exit();
      }
  ?&gt;
  </code></pre>