OK, going back to your original post there are a few problems.
Providing your original query looks like this:
$sql= "SELECT * FROM $table_name WHERE username = '$_POST[username]' AND password = password('$_POST[password]')";
When using Superglobals (e.g. $POST, $GET, $SERVER, etc.) inside a double qutoed string (as above) you must surround it with curly braces { and }. Also, the 'password' before ('$POST... should be in capitals because it is an SQL function. So now your query will look like:
$sql= "SELECT * FROM $table_name WHERE username = '{$_POST[username]}' AND password = PASSWORD('{$_POST[password]}')";
However there is still a problem with it. When reffering to something in a Superglobal (e.g. password in $_POST[password]) you must surround it with single quotation marks (unless it is a numbered array - which superglobals tend not to be). So the correct version of the query is:
$sql = "SELECT * FROM $table_name WHERE username = '{$_POST['username']}' AND password = PASSWORD('{$_POST['password']}')";
If the result of the query is true then the data submitted by the user is correct.
Furthermore, if you're picky like me selecting an entire row from a table is unnessecary when you don't need all of it. Just refer to one column if checking a username and password is all you need. On a site with high volume traffic the unnessecary memory usage builds up. Finally:
$sql = "SELECT username FROM $table_name WHERE username = '{$_POST['username']}' AND password = PASSWORD('{$_POST['password']}')";