title: PHP not working properly with html, js/jquery and ajax
body: <p>I have a simple registration form in html which is designed to "step by step" form.
  For that I am using javascript with ajax to call php which should send an email with values typed into inputs. But yesterday it sends email without that values and update to directory did not work. What happened today is that the same codes do not work anymore (and nothing was changed). Ajax only return error message which is put in alert.</p>
  
  <p>Here's the codes:</p>
  
  <p>HTML form:</p>
  
  <pre><code>&lt;form id="regForm" action="doneregister.php" method="post" enctype="multipart/form-data"&gt;
              &lt;div class="tab"&gt;
                  &lt;h1 class="reg"&gt;Kapitán tímu&lt;/h1&gt;&lt;br&gt;
                  &lt;p&gt;&lt;input type="text" name="meno" placeholder="Meno a priezvisko" oninput="this.className = ''"&gt;&lt;/p&gt;
                  &lt;p&gt;&lt;input type="text" name="nick" placeholder="Nick v hre" oninput="this.className = ''"&gt;&lt;/p&gt;
                  &lt;p&gt;&lt;input type="email" name="email" placeholder="Email" oninput="this.className = ''"&gt;&lt;/p&gt;
                  &lt;p&gt;&lt;input type="text" name="steamID" placeholder="Steam ID" oninput="this.className = ''"&gt;&lt;/p&gt;
              &lt;/div&gt;
              &lt;div class="tab"&gt;
                  &lt;h1 class="reg"&gt;Hráč 2&lt;/h1&gt;&lt;br&gt;
                  &lt;p&gt;&lt;input type="text" name="meno2" placeholder="Meno a priezvisko" oninput="this.className = ''"&gt;&lt;/p&gt;
                  &lt;p&gt;&lt;input type="text" name="nick2" placeholder="Nick v hre" oninput="this.className = ''"&gt;&lt;/p&gt;
                  &lt;p&gt;&lt;input type="text" name="steamID2" placeholder="Steam ID" oninput="this.className = ''"&gt;&lt;/p&gt;
              &lt;/div&gt;
              &lt;div class="tab"&gt;
                  &lt;h1 class="reg"&gt;Hráč 3&lt;/h1&gt;&lt;br&gt;
                  &lt;p&gt;&lt;input type="text" name="meno3" placeholder="Meno a priezvisko" oninput="this.className = ''"&gt;&lt;/p&gt;
                  &lt;p&gt;&lt;input type="text" name="nick3" placeholder="Nick v hre" oninput="this.className = ''"&gt;&lt;/p&gt;
                  &lt;p&gt;&lt;input type="text" name="steamID3" placeholder="Steam ID" oninput="this.className = ''"&gt;&lt;/p&gt;
              &lt;/div&gt;
              &lt;div class="tab"&gt;
                  &lt;h1 class="reg"&gt;Hráč 4&lt;/h1&gt;&lt;br&gt;
                  &lt;p&gt;&lt;input type="text" name="meno4" placeholder="Meno a priezvisko" oninput="this.className = ''"&gt;&lt;/p&gt;
                  &lt;p&gt;&lt;input type="text" name="nick4" placeholder="Nick v hre" oninput="this.className = ''"&gt;&lt;/p&gt;
                  &lt;p&gt;&lt;input type="text" name="steamID4" placeholder="Steam ID" oninput="this.className = ''"&gt;&lt;/p&gt;
              &lt;/div&gt;
              &lt;div class="tab"&gt;
                  &lt;h1 class="reg"&gt;Hráč 5&lt;/h1&gt;&lt;br&gt;
                  &lt;p&gt;&lt;input type="text" name="meno5" placeholder="Meno a priezvisko" oninput="this.className = ''"&gt;&lt;/p&gt;
                  &lt;p&gt;&lt;input type="text" name="nick5" placeholder="Nick v hre" oninput="this.className = ''"&gt;&lt;/p&gt;
                  &lt;p&gt;&lt;input type="text" name="steamID5" placeholder="Steam ID" oninput="this.className = ''"&gt;&lt;/p&gt;
              &lt;/div&gt;
              &lt;div class="tab"&gt;
                  &lt;h1 class="reg"&gt;Tím&lt;/h1&gt;&lt;br&gt;
                  &lt;p&gt;&lt;input type="text" name="nazov" placeholder="Názov tímu" oninput="this.className = ''"&gt;&lt;/p&gt;
                  &lt;p&gt;&lt;input type="text" name="skratka" placeholder="Skratka tímu" oninput="this.className = ''"&gt;&lt;/p&gt;
                  &lt;input type="file" name="file" required&gt;
                  &lt;p&gt;S odoslaním registrácie súhlasíte s &lt;a href="9wk4l81Gmo2PYYVvGa1c.php" target="_blank"&gt;Pravidlami a podmienkami&lt;/a&gt;&lt;/p&gt;
              &lt;/div&gt;
              &lt;div style="text-align:center;margin-top:40px;"&gt;
                  &lt;div style="float:right;"&gt;
                      &lt;button type="button" id="firstBtn" onclick="redirect();"&gt;Späť na WindCup&lt;/button&gt;
                      &lt;button type="button" id="prevBtn" onclick="nextPrev(-1)"&gt;Späť&lt;/button&gt;
                      &lt;button type="button" id="nextBtn" onclick="nextPrev(1)"&gt;Ďalej&lt;/button&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;div style="text-align:left;margin-top:50px;"&gt;
                  &lt;span class="step"&gt;&lt;/span&gt;
                  &lt;span class="step"&gt;&lt;/span&gt;
                  &lt;span class="step"&gt;&lt;/span&gt;
                  &lt;span class="step"&gt;&lt;/span&gt;
                  &lt;span class="step"&gt;&lt;/span&gt;
                  &lt;span class="step"&gt;&lt;/span&gt;
              &lt;/div&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>JS/jQuery and Ajax to call php:</p>
  
  <pre><code>function nextPrev(n) {
                  var x = document.getElementsByClassName("tab");
                  if (n == 1 &amp;&amp; !validateForm()) return false;
                  x[currentTab].style.display = "none";
                  currentTab = currentTab + n;
                  if (currentTab &gt;= x.length) {
                      jQuery.ajax({
                          type: "POST",
                          url: "doneregister.php",
                          data: jQuery("#regForm").serialize(),
                          success: function(response) {
                              if (response) {
                                  jQuery(location).attr('href', "www.windcup.sk/?register=1");
                              } else {
                                  alert("Error");
                              }
                          }
                      });
                      return false;
                  }
                  showTab(currentTab);
              }
  </code></pre>
  
  <p>And php code:</p>
  
  <pre><code>if(isset($_POST)) {
      //kapitan
      $meno = $_POST["meno"];
      $nick = $_POST["nick"];
      $email = $_POST["email"];
      $steamID =  $_POST["steamID"];
  
      //hrac 2
      $meno2 = $_POST["meno2"];
      $nick2 = $_POST["nick2"];
      $steamID2 =  $_POST["steamID2"];
  
      //hrac 3
      $meno3 = $_POST["meno3"];
      $nick3 = $_POST["nick3"];
      $steamID3 =  $_POST["steamID3"];
  
      //hrac 4
      $meno4 = $_POST["meno4"];
      $nick4 = $_POST["nick4"];
      $steamID4 =  $_POST["steamID4"];
  
      //hrac 5
      $meno5 = $_POST["meno5"];
      $nick5 = $_POST["nick5"];
      $steamID5 =  $_POST["steamID5"];
  
      //Tim
      $nazov = $_POST["nazov"];
      $skratka = $_POST["skratka"];
  
      //poslanie emailu
      $destination = 'info@windcup.sk';
      $predmet = 'Registrácia tímu';
      $obrazok = basename($_FILES["file"]["name"]);
      $sprava = "Kapitán tímu: $meno Nick: $nick Email: $email SteamID: $steamID\n Hráč2: $meno2 Nick: $nick2 SteamID: $steamID2\n Hráč3: $meno3 Nick: $nick3 SteamID: $steamID3\n Hráč4: $meno4 Nick: $nick4 SteamID: $steamID4\n Hráč5: $meno5 Nick: $nick5 SteamID: $steamID5\n Tím: $nazov Skratka: $skratka Názov obrázku: $obrazok";
      $mail = mail($destination, $predmet, $sprava);
  
      //obrazok
      $target_dir = "style/img/teams/";
      $target_file = $target_dir . basename($_FILES["file"]["name"]);
      $upload_ok = 1;
      $imageType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
      $check = getimagesize($_FILES["file"]["tmp_name"]);
  
      if($check !== false) {
          //je to obrazok
          $upload_ok = 1;
      } else {
          //nie je to obrazok
          $upload_ok = 0;
      }
  
      if($_FILES["file"]["size"] &gt; 500000) {
          $upload_ok = 0;
      }
  
      if($imageType != "jpg" &amp;&amp; $imageType != "jpeg" &amp;&amp; $imageType != "png" &amp;&amp; $imageType != "gif") {
          $upload_ok = 0;
      }
  
      if($upload_ok == 0) {
          echo "Error";
      } else {
          if(move_uploaded_file($_FILES["file"]["tmp_name"], $target_file)) {
              //nic
          } else {
              echo "Error";
          }
      }
  }
  </code></pre>
  
  <p>Thanks for help!</p>