I have a registration form and I want it to connect to my database. I used phpmyadmin as my database. The code that I used to connect the two is below:
db.php
<?php
$hostname = "127.0.0.1";
$user = 'root';
$password = '';
$db = 'dbTest';
//connection to db
$conn = mysqli_connect("$hostname", "$user", "$password", "$db")or die(mysqli_error());
mysqli_select_db($conn, "peanat")or die(mysqli_error());
    $username = $_POST['username'];
    $password = $_POST['password'];
    $username =  strtolower(trim($_POST["username"])); 
    $username = filter_var($username, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW|FILTER_FLAG_STRIP_HIGH);
    $checkUsername = mysqli_query($conn, "Select username * FROM users WHERE Username='$username'");
    $numrows = mysqli_num_rows($checkUsername);
        if($numrows!==1) {
        echo "Username not available";
    }else{
        $sql = "INSERT INTO `users` (`Username`, `Password`) VALUES ('$username', '$password')";
        if(!mysqli_query($conn, $sql)) {
            die(mysqli_error());
        } else {
             echo "1 record added";
        }
    }
?>
this is my reg form
<form id="register" action="db.php" method="post" >
      <div class="col-4">
        <label>
          Username
          <input placeholder="" id="username" name="username">
        </label>
      </div>
      <div class="col-4">
        <label>Password
        <input type="password" placeholder="" id="password" name="password">
        </label>
      </div>
      <div class="col-4">
        <label>Confirm Password
        <input type="password" placeholder="" id="password2" name="password2">
        </label>
      </div>
      <div class="col-submit">
        <input type="submit" class="submitbtn" name="register" value="Register">
      </div>
</form>
now the problem I'm encountering is, every time I click the register button, it just goes to the designated page and it shows the code of that page. where do you think is my error...
 
     
    