title: $.AJAX JQUERY/PHP login script with strange will of it's own
body: <p>Hello fellow programmers!</p>
  
  <p>I have a very annoying problem with a login script i've built.
  It's a script that sends the username variable and password variable from a HTML form with a $.AJAX (jquery) call to a check.php file. The variables are sent with a keyUp function in the JS. The trick is that there is no submit button and the user logs in automatically when the variables match up with the db. The check.php is OOP with multiple methods and when the vars match up with the db, the php sends a json_encode to the js. I want to keep the script and settings file seperated. When i put the database settings in check.php file, the script works. If i try to load them externally with an include at the top, the script doesn't work.<BR><BR>
  The JS:</p>
  
  <pre><code>$("#wachtwoord, #gebruikersnaam").keyup(function(){
      passnum = $("#wachtwoord").val();
      usernum = $("#gebruikersnaam").val();
  
      if(passnum.length &gt; 2 &amp;&amp; usernum.length &gt; 2) {
  
          $.ajax({
              type: "POST",
              url: "classes/check.php",
              dataType: 'json',
              data: "gebruikersnaam="+usernum+"&amp;wachtwoord="+passnum, 
              success: function(check){
                            if(check.login == 'true') { 
                        Do Stuff!
  </code></pre>
  
  <p>The PHP:
  <BR></p>
  
  <pre><code>(other methods and other unnecessary stuff above these lines of code...)
  public function check(){
  
  
              if ($_POST){
              $u = $_POST['gebruikersnaam'];
              $u = strtolower($u);
              $u = trim($u);
              $p = $_POST['wachtwoord'];
              mysql_connect(host, user, pw);
              mysql_select_db(db);
  
                  $gebruiker = mysql_real_escape_string($u);
                  $wachtwoord = mysql_real_escape_string($p);
                  $query = mysql_query("SELECT * FROM gebruikers WHERE gebruikersnaam = '".$gebruiker."' AND wachtwoord = '".$wachtwoord."'");
              if(mysql_num_rows($query))
              {
          $this-&gt;validate();
          }
  
      }
  }
  
  public function validate(){
          $return['login'] = "true";
          echo json_encode($return);  
  </code></pre>
  
  <p>I find it especially strange that the script in this form works, but when i include a file it doesn't return the json back to the JS. 
  I tried multiple things, but nothing seems to help. Even when i include a blank php file, the script stops working.
  The thing is, that i want to load all configuration data in a separate file and i don't want the my_sql data to be present in the login/check php file.</p>
  
  <p>Any thoughts on this?</p>
  
  <p>I'm getting a nasty headache because of this strange problem.</p>
  
  <p>Hope i'm making a dumb mistake!</p>
  
  <p>Thanks in advance!</p>
  
  <p>RJ</p>