title: How to create a new mySQL database user from php
body: <p>I was wondering if there was a way to create a new user for my MySQL Database? I'm trying to add basic log-in functionality that will allow the user to connect to database. If user has no account, then I want to create a new one. This is what I have so far: </p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Test&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
     &lt;?php
          $username = "root";
          $password = "root";
          $hostname = "localhost"; 
  
          //connection to the database
          $dbhandle = mysql_connect($hostname, $username, $password) 
            or die("Unable to connect to MySQL");
          echo "Connected to MySQL&lt;br&gt;"; 
          $selected = mysql_select_db("contactsDB",$dbhandle) 
              or die("Could not select examples");    
          echo "Found contacts DB";
          ?&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>Everything connects properly, but now, instead of having to type in the username and password (root), I want user to type their username and password. Again, if they don't have one, then I want to create a new one. </p>