title: self submit form acces variables javascript
body: <p>I'm making a site for some peaple of my class and I want them to be able to login. I don't want to make an extra loginpage, so I created this bit of code for my login system, but it doesn't work. I looked al over the internet to find other soloutions, but with no success... I want the person to type in their username and password and I want to store that information in a javascript function, so that I can do a function like tis:</p>
  
  <pre><code>function passCheck  () {
      if (pass="johndohpassword1234") // userbname johndoe and passsword password1234 
      {
          document.getElementById('h').innerHTML= "welcome, John!";
      }
  </code></pre>
  
  <p>this is my code:
  <div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  
  $id = $_POST[username] . $_POST[password];
  
  ?&gt;
  
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Login&lt;/title&gt;
      &lt;script type="text/javascript" src="script.js"&gt;
    
          var pass=" &lt;?php echo "$id"; ?&gt;";
          window.alert( "welkom, " + pass );
  
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1 id="h"&gt;Login&lt;/h1&gt; &lt;br&gt;
      &lt;form action="http://timkast.tk" method="post"&gt;
          &lt;b&gt;Username:&lt;/b&gt;&lt;input type="text" name="username"&gt; &lt;br&gt;
          &lt;b&gt;Password:&lt;/b&gt;&lt;input type="password" name="password"&gt;&lt;br&gt;
          &lt;input type="submit"&gt;&lt;/input&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt; </code></pre>
  </div>
  </div>
  </p>
  
  <p>everything works fine, but the code for <code>window.alert</code> does nothing and I dont know why, please can someone explain/fix this?</p>