I am trying to have an if statement appear if a user is logged in. Here is the code
PHP Code:
<?php 
require 'classLogin.php';

?>
<!DOCTYPE html>
<html lang="en">
  <head>
<title>Login</title>
  </head>

  <body>

    <div class="container">

      <form method="post" action="form.php">
        <h2>Please sign in</h2>
        <input type="text" class="form-control" name="user_name" placeholder="Email address" value="<?php if(isset($_POST['user_name'])) { echo ($_POST['user_name']);} ?>" >
        <input type="password" class="form-control" name="user_password" placeholder="Password" autofocus>
        <button name="submit" type="submit">Sign in</button>
      </form>
<?php 
$classLogin 
= new Login;


if(isset(
$_POST['submit'])) {
$classLogin->loginWithPostData();
}

if (
$user_is_logged_in true) {
echo 
"USER IS LOGGED IN";
}
?>
    </div>




  </body>
</html>
PHP Code:
          public $user_is_logged_in false;



public function 
loginWithPostData()
{
if ((
$query->num_rows == 1) && ($_POST['user_password'] === $result->user_password)) {
 
 
            echo 
"You are now logged in " $this->user_name "";
            return 
$this->user_is_logged_in true;
                     } 

For some reason the echo "USER IS LOGGED IN" appears no matter what I type in the statement such as "
PHP Code:
if ($user_logd_in tr
"

Ive been stuck for a few hours now so hopefully somebody can determine the issue and hopefully show an efficient way to do something like this.