Problems with passing variables in the post method

Created the following post1.php file, with this form to submit:

<form action="post2.php" method="post" name="form1" target="_blank">
<p>  :<br> <input name="name" type="text" size="20" /></p>
<p>  :<br> <input name="lastname" type="text" size="20" /></p>
<p><input name="submit" type="submit" value="" /></p>

in another file – post2.php wrote the output:

echo $_POST[$name];
echo "$lastname";

but when the code is implemented, nothing happens. The post2 page opens in a new window, but does not display either the first or last name. Where is my mistake, please tell me.

Answer 1, authority 100%