title: Check if username is being used
body: <p>I'm wondering if and how I could check if a username is being used.</p>
  
  <p>I heard you can do this with <strong>jQuery</strong> but i just want something simple since I'm a beginner.</p>
  
  <p>I have tried it but i can't seam to get it right. I just have it connected to a mysql database but since when a username with the same password as another account tries to logon, theres an issue, so i need this to stop people adding multiple usernames.</p>
  
  <p>Here is my simple code for the registration form and the php</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form action="" method="POST"&gt;
      
      &lt;p&gt;&lt;label&gt;name&amp;nbsp;&amp;nbsp; : &lt;/label&gt;
    &lt;input id="password" type="text" name="name" placeholder="name" /&gt;&lt;/p&gt;
    
      &lt;p&gt;&lt;label&gt;User Name : &lt;/label&gt;
   &lt;input id="username" type="text" name="username" placeholder="username" /&gt;&lt;/p&gt;
   
   &lt;p&gt;&lt;label&gt;E-Mail&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : &lt;/label&gt;
    &lt;input id="password" type="email" name="email"/&gt;&lt;/p&gt;
   
       &lt;p&gt;&lt;label&gt;Password&amp;nbsp;&amp;nbsp; : &lt;/label&gt;
    &lt;input id="password" type="password" name="password" placeholder="password" /&gt;&lt;/p&gt;
   
    
   
      &lt;a class="btn" href="login.php"&gt;Login&lt;/a&gt;
      &lt;input class="btn register" type="submit" name="submit" value="Register" /&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  &lt;?php
  
   require('connect.php');
      // If the values are posted, insert them into the database.
      if (isset($_POST['username']) &amp;&amp; isset($_POST['password'])){
          $username = $_POST['username'];
    $email = $_POST['email'];
          $password = $_POST['password'];
          $name = $_POST['name'];
   
          $query = "INSERT INTO `user` (username, password, email, name) VALUES ('$username', '$password', '$email', '$name')";
          $result = mysql_query($query);
          if($result){
        
          }
      }
  
  ?&gt;</code></pre>
  </div>
  </div>
  </p>