Sorry about adding the _required. I looked at your form wrong the first time.
You should check to make sure your register globals is on... either that or add the following:
extract($_POST);
above your query.
This will extract the form variables you are passing with your POST method, so you should get the following variables:
$UN_required = You fool! You need a username.
$PWD_required = For cryin' out loud...enter a password
$UN = (The entered user name)
$PWD = (The entered password)
Also, in your select query, add the $ sign to your variables...
$sql = "SELECT * FROM $table_name WHERE name=$UN AND pass=$PWD";
This way your SQL statement knows you are trying to compare the name and pass fields with variables instead of with trying to compare with text. I think your SQL atatement is being tried literally. In other words, the query is looking for a name of UN and a password of PWD literally...