i am new in PHP learning try to add some data in database ,all the solutions available in net is tried but can not solve my issue :      // this is my php code starting and used connection type is pdo 
    
     //connection with server
        $servername = "localhost";
        $username = "root";
        $password = "";
    try {
       $conn = new PDO("mysql:host=$servername;dbname=gujaratoil", $username, 
       $password);
       $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            echo "Connected successfully";
    }
    catch(PDOException $e)
       {
        echo "Connection failed: " . $e->getMessage();
       }

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

        //at the beginig null value is set

        $name=$emailaddress="";
        $sql="INSERT INTO                                                                                                                                                                         
        registration(name,emailaddress)VALUES('$_POST[name]','$_POST[emailaddre 
        ss]')";                                         }}
          ?>              
haves try all the solutions available what should i do to solve this issue. have try pdo connection 

please do suggest it is urgent 