I'm a beginner in php. The code seemed right but when I try to insert the data from the form to the database, it doesn't enter to the database. What is wrong with my code?
Here's my code
addemployee.php
echo '<form action="addemployee.php" method="POST">';
echo '<table align ="center">';
echo '<tr><td>First Name: </td> <td><input type="text" name="first" pattern="[A-Za-z]{1,}" title="A-Z only" required></td> </tr>';
echo '<tr><td>Middle Initial: </td><td><input type="text" name="middle"></td></tr>';
echo '<tr><td>Last Name:</td><td> <input type="text" name="last"></td></tr>';
echo '<tr><td>Contact Number:</td><td> <input type="tel" name="contact" maxlength="11"></td></tr>';
echo '<tr> <td>Province: </td><td> <input type="text" name="provincee"></td></tr>';
echo '<tr> <td>City: </td><td> <input type="text" name="cityy"></td></tr>';
echo '<tr> <td>Username:</td><td> <input type="email" name="usernamee"></td></tr>';
echo '<tr><td>Password:</td><td> <input type="password" name="pass"></td></tr>';
echo '</table>';
echo '<br> <input type="Submit" name="submitt">';
if(isset($_POST['submitt'])){
$firstname=$_POST['first'];
$middleinitial=$_POST['middle'];
$lastname=$_POST['last'];
$contactnumber=$_POST['contact'];
$province= $_POST['provincee'];
$city =$_POST['cityy'];
$username=$_POST['usernamee'];
$password=$_POST['pass'];
$type= 'employee';
$query=("INSERT INTO usertbl (fname,middeinitial,lname,contactnum,province,city,username,password,type) VALUES ('$firstname','$middleinitial','$lastname','$contactnumber','$province',
'$city','$username','$password','$type')");
mysqli_query($db, $query);
}
echo '</form>';