im currently have 2 problems. The undefined variable and mysqli_real_escape_string
These are the notice and warning:
Notice: Undefined variable: con in C:\xampp\htdocs\ngab\login.php on line 14
Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\ngab\login.php on line 14
Notice: Undefined variable: con in C:\xampp\htdocs\ngab\login.php on line 16
Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\ngab\login.php on line 16
Notice: Undefined variable: con in C:\xampp\htdocs\ngab\login.php on line 18
Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\ngab\login.php on line 18
Notice: Undefined variable: con in C:\xampp\htdocs\ngab\login.php on line 21
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\ngab\login.php on line 21
These are my codes:
<!DOCTYPE html>
   <html>
    <head>
    <meta charset="utf-8">
    <title>Login</title>
    <link rel="stylesheet" href="css/style.css" />
    </head>
    <body>
     <?php
     require('db.php');
     session_start();
     if (isset($_POST['username'])){
        $user_ID = stripslashes($_REQUEST['user_ID']);
         $user_ID = mysqli_real_escape_string($con,$user_ID);
         $username = stripslashes($_REQUEST['username']);
         $username = mysqli_real_escape_string($con,$username);
$password = stripslashes($_REQUEST['password']);
$password = mysqli_real_escape_string($con,$password);
    $query = "SELECT * FROM `teacher_table` WHERE user_ID='$user_ID' 
    and username='$username' and password='".md5($password)."'";
$result = mysqli_query($con,$query) or die(mysql_error());
$rows = mysqli_num_rows($result);
    if($rows==1){
    $_SESSION['username'] = $username;
    header("Location: home.php");
     }else{
echo "<div class='form'>
   <h3>User ID/username/password is incorrect.</h3>
    <br/>Click here to <a href='login.php'>Login</a></div>";
}
}else{
   ?>
     <div class="form">
   <h1>Log In</h1>
    <form action="" method="post" name="login">
   <input type="text" name="user_ID" placeholder="User ID" required />
    <input type="text" name="username" placeholder="Username" required />
    <input type="password" name="password" placeholder="Password" required />
    <input name="submit" type="submit" value="Login" />
     </form>
    <p>Not registered yet? <a href='registration.php'>Register Here</a></p>
     </div>
     <?php } ?>
     </body>
     </html>
And this is the db.php is:
    <?php
     $connect=mysql_connect("localhost","root","");
     if(!$connect)
     {
       echo "Error".mysql_error();
        }
       $db=mysql_select_db("attendance_db");
       if(!$db)
        {
           echo "Error".mysql_error();
           }
          ?>
Thanks. I would like to know whats wrong and how to fix it?
 
     
    