Change
$name = $_POST["$name"];
to
$name = $_POST["name"];
the dollar sign shouldn't be in there
["$name"]
^-- // remove this
Add error reporting to the top of your file(s) right after your opening <?php tag
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// rest of code
Having done this, would've thrown an error similar to this:
Notice: Undefined variable: name in...(path of file) on line X
To learn more on error reporting, visit:
Also, go through the PHP.net website. http://php.net
You can browse through their website where examples are shown. No better way to start than in the manuals themselves.
PHP forms on PHP.net
Footnotes:
Also, you are open to XSS attacks (Cross-site scripting).
Use the following (PHP) filter function: FILTER_SANITIZE_FULL_SPECIAL_CHARS
$name = filter_var($_POST['name'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
Equivalent to calling htmlspecialchars() with ENT_QUOTES set. Encoding quotes can be disabled by setting.
Edit:
As per Jeremy1026's comment:
"by doing $_POST["$name"] you are basically doing, $name = foo; $_POST['foo'];"
Thank you for the additional comment in order to improve the answer.