Your code has got a few flaws in it first of all you never actually populate the $rows variable and your select is a bit abigious. your login script should be more like
<?
$user = $_POST['user'];
$password =$_POST['password'];
// make connection to database
$connect = mysql_connect($host, "username", "password")
or die("Could not connect");
//select the working database
mysql_select_db("usernames") or die("Could not select database");
//base query on username and password.
$query="select * from register where user like '".$user."' and password like '".$password."'";
$result = mysql_query($query) or die("Query failed");
if ($result)
{
echo("You may enter");
}
else
{
echo("Incorrect username and Password");
}
MySQL_close()
?>
Oh you should also be storing the passwords encrypted. using the password() function of mysql. the storage using the earlier example would be
$sql = "INSERT INTO user (name, lname, user, password, email, company, tel) values (";
$sql.="\"".addslashes($name)."\", ";
$sql.="\"".addslashes($lname)."\",";
$sql.="\"".addslashes($user)."\",";
$sql.="\"password(".$password.")\",";
$sql.="\"".addslashes($email)."\",";
$sql.="\"".addslashes($company)."\",";
$sql.="\"".addslashes($tel)."\")";
then you would replace the query from earlier with
$query="select * from register where user like '".$user."' and password like password('".$password."')";
This will store the encrypted password in the database and also compare the password with it still encrypted.