title: jQuery check mysql database if username is already taken
body: <p>i know that this is possible but i am confused as to how it works. I have been looking online for how it is done and I think i am missing something in the process</p>
  
  <p>I have this jQuery code so far:</p>
  
  <pre><code>$("#Contact_Info").validate({  
          rules: {
              username: {
                  required: true,
                  minlength: 6,
                  remote: "check-username.php"
                  }
              },
          messages: {
              username:{
                  remote: "This username is already taken! Try another."
              }
          }
    });
  </code></pre>
  
  <p>How should i write my php page to make it talk to the jQuery code?</p>
  
  <p>So far I have:</p>
  
  <pre><code>$name = mysql_real_escape_string($name);
  
  $query = "SELECT USERNAME FROM T_MEMBER WHERE USERNAME='$name';";
  $res = mysql_query($query);
  if (mysql_num_rows($res) &gt; 0) {
     return false;
  } else
     return true; 
  </code></pre>
  
  <p>How do I get the $name variable from the javascript? Do i have to set the "remote" to be POST?</p>
  
  <p>Thanks in advance,
  Ian McCullough</p>