// check this solution for you
<html>
<body>
<?php
$con=mysql_connect("localhost","username","password"); // connection to localhost
if(!$con)
{
die('Could not connect :'.mysql_error()); // showing error if having problem with username or password
}
mysql_select_db("database_name",$con); // select database from localhost
$sql="INSERT INTO table_name(fname, lname)
VALUES('$_POST[fname]','$_POST[lname]')"; // inserting record into table
if(!mysql_query($sql,$con))
{
die('Error in inserting record :'.mysql_error()); // if problem with tablename or any field name
}
echo "1 record added"; // record added successfully
mysql_close($con) // close connection to server
?>
</body>
</html>