title: Too many redirects. XAMPP ; Localhost; MYSQL (PHPMYADMIN)
body: <p>I am using XAMPP for connecting a DB with PHP myadmin and a test-webpage which runs on a localhost Webserver via Apache. 
  I uploaded all files to the htdocs folder. When I now run the webpage and try to "register" for that dummy-page on localhost the Browser throws the error-message: ERR_TOO_MANY_REDIRECTS . 
  Supringsingly, the data I send with the "sign up-button" is written in the DB, which I can check via the PHP myadmin console. </p>
  
  <p>I think it is a problem of htacess and I have questions about that. </p>
  
  <p>Where should the htacess file be? In the same directory with my other files? 
  What should be in the htacess file? I dont want to upload it to the internet, so it is just for learning purposes and should stay in localhost.</p>
  
  <p>I hope I could describe the problem well enough.
  First my Index File:</p>
  
  <pre><code>&lt;?php
  
  session_start();
  
  $error = "";
  
  if(array_key_exists("logout", $_GET)){
  
      unset($_SESSION);
      setcookie("id", "", time() - 60*60);
      $_COOKIE["id"] = "";
  
  }else if(array_key_exists("id",$_SESSION) OR array_key_exists("id", $_COOKIE)){
  
      header("Location: loggedinpage.php");
  
  }
  
  
  if(array_key_exists("submit", $_POST)){
  
      include("connection.php");
  
  
      if(!$_POST['email']){
  
          $error .= "Die Emailadresse fehlt&lt;br&gt;";
  
      }
  
      if(!$_POST['password']){
  
          $error .= "Passwort wird benötigt&lt;br&gt;";
  
      }
  
      if($error != ""){
  
          $error = "&lt;p&gt;Es gab Fehler in deinem Formular&lt;/p&gt;".$error;
  
      }else {
  
          if($_POST['signUp'] == '1'){
  
                 $query = "SELECT id FROM users WHERE email = '".mysqli_real_escape_string($link, $_POST['email'])."' LIMIT 1";
  
                  $result = mysqli_query($link, $query);
  
                  if(mysqli_num_rows($result) &gt; 0){
  
                      $error = "Diese email ist bereits vergriffen.";
  
                  }else{
  
                      $query = "INSERT INTO users (email, password) VALUES ('".mysqli_real_escape_string($link, $_POST['email'])."',
                      '".mysqli_real_escape_string($link, $_POST['password'])."')";
  
                      if(!mysqli_query($link, $query)){
  
                          $error = "&lt;p&gt;Registrieren hat nicht funktioniert, versuche es später noch einmal.&lt;/p&gt;";                    
  
                      }else{
  
                          $query = "UPDATE users SET password = '".md5(md5(mysqli_insert_id($link)).$_POST['password'])."' WHERE id = ".mysqli_insert_id($link)." LIMIT 1";
  
                          mysqli_query($link, $query);
  
                          $_SESSION['id'] = mysqli_insert_id($link);
  
                          if($_POST['stayLoggedIn'] == '1'){
  
                              setcookie("id", mysqli_insert_id($link), time() + 60*60*24*365);
  
                          }
  
                          header("Location: loggedinpage.php");
  
                      }
                  } 
  
  
          }else if($_POST['signUp'] == '0'){
  
              $query = "SELECT * FROM users WHERE email = '".mysqli_real_escape_string($link, $_POST['email'])."'";
  
              $result = mysqli_query($link, $query);
  
              $row = mysqli_fetch_array($result);
  
              if(isset($row)){
  
                    $hashedPassword = md5(md5($row['id']).$_POST['password']);
  
                      if($hashedPassword == $row['password']){
  
                          $_SESSION['id'] = $row['id'];
  
                          if($_POST['stayLoggedIn'] == '1'){
  
                              setcookie("id", mysqli_insert_id($link), time() + 60*60*24*365);
  
                          }
  
                          header("Location: loggedinpage.php");
  
                      }else{
  
                          $error = "Deine Email Passwort Kombination konnte nicht gefunden werden.";
  
                      }
  
              }else{
  
                   $error = "2 Deine Email Passwort Kombination konnte nicht gefunden werden.";
  
              }
  
  
          }
  
  
  
  
      }
  
  
  
  
  
  }
  </code></pre>