title: How should I handle the case in which a username is already in use?
body: <p>To practice PHP and MySQL development, I am attempting to create the user registration system for an online chess game.</p>
  
  <p>What are the best practices for:</p>
  
  <ul>
  <li><p>How I should handle the (likely) possibility that when a user tries to register, the username he has chosen is already in use, particularly when it comes to function return values? Should I make a separate SELECT query before the INSERT query?</p></li>
  <li><p>How to handle varying page titles?<br/>(<code>$gPageTitle = '...'; require_once 'bgsheader.php';</code> is rather ugly)</p></li>
  </ul>
  
  <p>(An excerpt of the code I have written so far is in the history.)</p>