Okay, since now I know that you're using MySQL, as well as a table named 'login' and its columns, I can lead you toward a more useful solution.
I'll assume that you already have established working connection and database selection code; and that you're using the POST method on your user-world form. A simple username and password check query might consist of the following code:
// First, build the query. Since we already have a username and password as provided from user-world, we should only need to select the 'id' column.
// In other words, if a row matches the username and password the *only* unknown should be the 'id':
$q = sprintf("SELECT id FROM login WHERE username=\"%s\" AND password=\"%s\"", $_POST['username'], $_POST['password']);
// Run the query. $r represents a result set identifier.
// If the query fails, there'll be no result set identifier.
$r = mysql_query($q);
// If there's no result set identifier, the query is bad and mysql should kindkly return an error message:
if(!$r) {
echo "Query $q failed: " . mysql_error();
} else {
// Just because there's a result set identifier, doesn't necessarily mean there are rows of data associated.
// Which is another way of saying 'the query is good, but no data matches it'.
if(!mysql_num_rows($r)) {
echo "Username or Password is incorrect.";
// This would be a good place to include() a login form...
} else {
// Since we're only requesting a single column, we'll stick with fecth_row() rather than fetch_array():
while($row = mysql_fetch_row($r)) {
$login_id = $row[0];
}
// Free up the resources associated with the result set. That's just good programming practice.
mysql_free_result($r);
}
}
// At this point, you should have $login_id available in your script for further use, or you should have seen one of the echo messages...
As I mentioned in my previous post, it's best to assure that usernames are unique by building that into your database structure. If that is the case, you should be able to safely omit the while() statement, since only one row will be present in a result set:
$row = mysql_fetch_row($r);
$login_id = $row[0];
Hope this is helpful...