Accessing a particular inputted Mysql user to php
<p><strong>I want an inputted name of user and password(optional) of mysql user to be the one used as user instead of the default root. How do I improve this code where it can notify me that I have successfully used the user and warned me if the user is non existent.</strong></p>

<pre><code>&lt;form class="box login" method="post"&gt;
&lt;fieldset class="boxBody"&gt;
  &lt;label&gt;Username&lt;/label&gt;
  &lt;input type="text" tabindex="1" placeholder="Username" required name="username"&gt;
  &lt;label&gt;&lt;label class="rLink" tabindex="5"&gt;Optional&lt;/label&gt;Password&lt;/label&gt;
  &lt;input type="password" tabindex="2" placeholder="Password" name="password" &gt;
&lt;/fieldset&gt;
&lt;footer&gt;

  &lt;input type="submit" class="btnLogin" value="Login" tabindex="4" name="submit"&gt;
&lt;/footer&gt;
</code></pre>

<p></p>

<pre><code>&lt;?php

if (isset($_POST['submit'])) {

$username=$_POST['username'];
$password=$_POST['password'];

$servername = "localhost";
$user = $username;
$pass = $password;

 if (empty($_POST['username'])) {
            echo  "Username can't be empty!"; }
    else {
        $conn = mysqli_connect($servername, $user, $pass);
            if (!$conn) {
                 die("Connection failed: " . mysqli_connect_error()); }
                    echo "Connected successfully"; }
}
?&gt; 
</code></pre>