Could someone help me understand why this code actually works? : <p>I've been following the Laracasts "PHP Practitioner" series to help me get a basic understanding of PHP and at this point, my code works fine and doesn't return any errors, but I can't quite grasp how it actually works.</p>

<p>If you've watched the series, in <a href="https://laracasts.com/series/php-for-beginners/episodes/20" rel="nofollow noreferrer">Episode 20</a>, in our QueryBuilder.php file, we create an insert method with 2 parameters "$table" and "$parameters". I get why "$table" works as we assign it to the 'users' table in the add-name.php file, but how does the text in the form get submitted to the database via the $parameters param? I'm not exactly following the logic so well and I just want to fully understand what's happening here. </p>

<p>For those of you who haven't watched the series and have no idea what I'm talking about, we basically make a simple form with an input and a submit button and at this point, we are sending the info from the form into a DB. Here's the snippet from the QueryBuilder.php file:</p>

<pre><code>public function insert($table, $parameters)
    {
        $sql = sprintf(
         'INSERT INTO %s(%s) values (%s)', 
         $table, 
         implode(', ', array_keys($parameters)),
         ':' .implode(', :', array_keys($parameters))
        );

        try{
        $statement = $this-&gt;pdo-&gt;prepare($sql);
        $statement-&gt;execute($parameters);

    } catch (Exception $e){
            die($e-&gt;getMessage());
        }
    }
</code></pre>

<p>and here's the add-name.php file:</p>

<pre><code>&lt;?php

$app['database']-&gt;insert('users', [
    'name' =&gt; $_POST['name']
]);

header('Location: /laracasts/PHP');
</code></pre>
