PHP variable not passing correctly to Javascript
<p>I am trying to validate input login via javascript by passing PHP variables. I cannot execute it properly for some reason. I'd appreciate your comments. Here's the code:</p>

<p>PHP:</p>

<pre><code>$personal = mysqli_query($connect,"SELECT * FROM basic ORDER BY user_id DESC ");
while($row = mysqli_fetch_array($personal)){
    $user = $row['username'];
    $user_password = $row['password'];
}
</code></pre>

<p>Javascript / jQuery:</p>

<pre><code>function enter_log() { 
    var login_username =  $("#username_field_log");
    var pass_password =  $("#pass_field_log");
    var button =  $("#enter_field_log");
    var php = "&lt;?= echo $user; ?&gt;";

    if ((login_username.val() == "") || (pass_password.val() == "")) { 
        $("#user_log_info").fadeIn('slow');
        $("#user_log_info").text("Not a proper login input");
        login_username.addClass("error");
        pass_password.addClass("error");
        return false;
    }
    else if ((login_username.val() != php ) || (pass_password.val() == "")) { 
        $("#user_log_info").fadeIn('slow');
        $("#user_log_info").text("Not a proper login input");
        login_username.addClass("error");
        pass_password.addClass("error");
        return false;
    } 
}
</code></pre>

<p>So in other words - the code should return false ( and it does so ) when the fields are empty but it doesn't return TRUE when the input is correct ( I mean when the username is correct ) so I assume the PHP variable <code>$user</code> is not passed by correctly to javascript?</p>
