title: PHP after Register success show JS Alert
body: <p>I have a login with a register process function like this:</p>
  
  <pre><code>if($result) {
      echo '&lt;script type="text/javascript"&gt; window.location.href = "index.php"; &lt;/script&gt;';
      include ("alert.php");
      $showFormular = false;
  } else {
      echo 'Beim Abspeichern ist leider ein Fehler aufgetreten&lt;br&gt;';          
  }
  </code></pre>
  
  <p>But i want that if the $result in top, a javascript with an alert is running,but it dosnt work.The alert code is:</p>
  
  <pre><code>&lt;script src = "https://cdn.jsdelivr.net/sweetalert2/6.6.2  /sweetalert2.min.js"&gt; &lt;/script&gt;
  &lt;link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/sweetalert2/6.6.2/sweetalert2.min.css"&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/core-js/2.4.1/core.js"&gt; &lt;/script&gt;
  
  &lt;script&gt;
  window.onload = function ()
  {
      swal({
          title:"Erfolgreich",
          type:"success",
          background:"#f2f2f2",
          confirmButtonColor:"#0080ff"
      })
  }
  &lt;/script&gt;
  </code></pre>