Firstly, mysqli_real_escape_string() requires a database connection be passed as the first parameter, as outlined in the manual:
Procedural style:
string mysqli_real_escape_string ( mysqli $link , string $escapestr )
Therefore, you need to change:
$username = mysqli_real_escape_string($username);
$password = mysqli_real_escape_string($password);
to:
$username = mysqli_real_escape_string($db, $username);
$password = mysqli_real_escape_string($db, $password);
Having checked for errors, would have thrown you an error, by checking for them in your query:
$query = mysqli_query($db, $sql) or die(mysqli_error($db));
Reference:
Then, since you haven't posted your HTML, it's unsure of the syntax you're using. Therefore, it should look something like this, and making sure there is a POST method and that the elements bear the correct name attributes.
I.e.:
<form action="handler.php" method="post">
<input type="text" name="username">
<input type="password" name="password">
<input type="submit" name="submit" value="SUBMIT">
</form>
Assuming an successful mysqli_ connection. If you are using anything other than the mysqli_ API to connect with, then you won't be able to query at all.
Different MySQL APIs do not intermix. You must use the same API from connection to querying.
References:
Another thing, your entire code's execution relies on this conditional statement:
if($_POST['login']){...}
If there isn't an element of that same name attribute, then nothing will fire at all.
It's also best to use isset() if(isset($_POST['login'])){...}, which I am under the impression is a submit button.
Sidenote: You're also including include_once "inc/connect.php"; twice; remove one.
Add exit; for your header, otherwise your code may want to continue to execute:
header("Location: board.php");
exit;
You also need to make sure that your database does indeed have the right data for the username/password, that the password was indeed hashed using MD5 (more about your use of MD5, below and under Passwords), that they're of the correct type and their lengths long enough.
Add error reporting to the top of your file(s) which will help find errors.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// rest of your code
Sidenote: Displaying errors should only be done in staging, and never production.
Passwords
I noticed that you are using MD5 as a password hashing storage function.
It is old and no longer considered safe to use in this day and age. A lot of water has gone under the bridge in 30+ years.
Use one of the following:
Other links:
About sessions:
If you're using sessions in other pages, make sure that the session was started in those pages also.
session_start(); must reside inside all pages using sessions.
Reference: