you can use ajax to get the data like this . use this function in you user.html
<div id="var" type="hidden"/>
$(document).ready(function(){
$.ajax({
url: 'user_check.php', // link your page
type: 'POST',
data: {
//'key1': data1,
// 'key2': data2
//if you want to post somethig
},
success: function(data) {
// got success data
$('#var').html(data); // set value in the div
},
error: function(data) {
// if error occure
alert('Some Error Occurred. Please Try Later.');
}
});
});
in your user_check.php echo what you want to show . as ajax will display the data which will print
<? php
echo $var="1021";
?>
Note you may need to include jquery library for this
if jquery is not present . include this cdn
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
if you want to know more about how .ajax work follow this refrence or refrence2
update
Another way to do this is include user.html after variable declaration .then user_check.php will
<?php
$var="1021";
include('user.html');
?>
and user.html will
<div id="var" type="hidden"><?php echo $var; ?></div>
mvc??