PHP更新不起作用

In my MySQL database I've one column with name CHECK where I have value just 1 or 0 and when one user login on my site this value put on 1 and when he logout it put 0. But.... I don't have any idea why this code don't want to put 1 on my column, have anyone any idea?

Or if anyone have an idea with how I can check if one user is already login or no pls tell me :)

Here are my database table enter image description here

if ($username && $password_sha1) {
    $query = mysqli_query ( $conn, "SELECT * FROM portofoliu_table WHERE account= '$username'" );
    $numrows = mysqli_num_rows ( $query );

    $val = 1;

    if ($numrows != 0) {

        while ( $row = mysqli_fetch_assoc ( $query ) ) {
            $db_account = $row ['account'];
            $db_password = $row ['password'];
        }
        if ($username == $db_account && $password_sha1 == $db_password) {

            //----------------------------------------HERE--------------------------------------------------------
            mysqli_query ( $conn, "UPDATE portofoliu_table SET check = '$val' WHERE account= '$username'" );
            //----------------------------------------------------------------------------------------------------

            $_SESSION ['account'] = $username;
            $_SESSION ["logged"] = true;

            header ( "location: AboutMe.php" );
            exit ();
        } else {
            echo "<div id='err'>Your password is incorrected</div>";
        }
        $_SESSION ["logged"] = false;
        exit ();
    } else {
        die ( "<div id='err'>That user don't exists</div>" );
    }
} else {
    die ( "<div id='err'>Please enter a username and password</div>" );
}

Try this?

<?
if ($username && $password_sha1) {
    $query = mysqli_query ( $conn, "SELECT * FROM portofoliu_table WHERE `account`='$username'" );
    $numrows = mysqli_num_rows ( $query );

    $val = 1;

    if ($numrows > 0) {

        while ( $row = mysqli_fetch_assoc ( $query ) ) {
            $db_account = $row['account'];
            $db_password = $row['password'];
        }
        if ($username == $db_account && $password_sha1 == $db_password) {

            //----------------------------------------HERE--------------------------------------------------------
            mysqli_query ( $conn, "UPDATE portofoliu_table SET `check`='$val' WHERE `account`='$username'" );
            //----------------------------------------------------------------------------------------------------

            $_SESSION['account'] = $username;
            $_SESSION["logged"] = true;

            header ( "location: AboutMe.php" );
            exit ();
        } else {
            echo "<div id='err'>That password is incorrect.</div>";
        }
        $_SESSION["logged"] = false;
        exit ();
    } else {
        die ( "<div id='err'>That user does not exist.</div>" );
    }
} else {
    die ( "<div id='err'>Please enter a username and password</div>" );
}
?>