I am trying to insert html form data in database through php. I am unable to insert html form data into database , i donot know , what i am doing wrong in my code?
Here is my code:
<?php
$host = 'localhost';
$username = 'root';
$password = '';
$dbname = 'mydb';
$con=mysqli_connect($host, $username, $password,$dbname);
if (!$con) 
{
    echo "connection failed";
}
if(isset($_POST['submit']))
{
 $name = $_POST['username'];
 $pass = $_POST['password'];
$sql="insert into mytable1 (name,password) VALUES ('$name', '$pass')";
    if(mysqli_query($con,$sql))
    {
        echo "DATA IS INSERTED INTO DATABASE";
    }
}
?>
<!DOCTYPE HTML>
<html>
    <head>
        <title>SignUpform.com</title>
    </head>
    <body>
        <div id="div1">
            <div id="div2">
                <h1>Sign up Form</h1>
            </div>
           <form action="" method="post">
            <fieldset>
                <legend>Signup form ceredentials</legend>
                 <p id="p1">Name:</p>    
                <input id="text1" type="text" placeholder="Enter username" name="username">
                 <p id="p2">Password:</p>
                <input id="pass1" type="password" placeholder="Enter Password" name="password">
                <p id="email">Email:</p>
                <input id="emailtextfld" type="text" placeholder="Enter Email" name="email">
                <p id="company">Company Name:</p>
                <input id="companytextfld" type="text" placeholder="Company name" name="company">
                <input id="donebtn" type="submit" value="submit" name="submit">
            </fieldset>
           </form> 
        </div>
    </body>
</html>


 
     
     
    