I'm beginner for PHP and doing Login Project that I find problems with mysqli_real_escape with parameter $_POST
The Error: undefined index   so you think it might be duplicate topic but for this case it's in mysqli_real_escape function 
so I fix error with isset but it still have error: syntax error, unexpected 'if' (T_IF)
Here is my code.
session_start();
$con = mysqli_connect("localhost","root","", "test2");
$sql = "SELECT * FROM member WHERE Username = '".mysqli_real_escape_string($con, $_POST['username'])."'
AND Password = '".mysqli_real_escape_string($con, $_POST['password'])."'";
$query = mysqli_query($con, $sql);
This is my try.
mysqli_real_escape_string($con, if(isset($_POST['password'])) $_POST['password'])
Page: index.php
<form name="form1" method="post" action="login.php">
<b>Login</b><br><br>
    <table border="1" style="width: 300px">
        <tr>
            <td>  Username</td>
            <td><input type="text" name="username"></td>
        </tr>
        <tr>
            <td>  Password</td>
            <td><input type="password" name="password"></td>
        </tr>
    </table>
    <br>
        <input type="submit" name="Submit" value="Login">
          <a href="regispage.php"> Register </a>
 
     
    