First of all, you got your subject titles back to front. This one is about passing PHP variables to JavaScript.
Second, there's no point saying that it's urgent. It's not going to make anyone move any faster. Urgency is something you have to deal with.
Third, if you want PHP to write something inside JavaScript code, the result has to be valid JavaScript. Just outputting a random string like "SomeGuy" would result in a page with
<script type="text/javascript">
if(name==id25)
SomeGuy
</script>
in it. It would need to be something more like
<script type="text/javascript">
if(name==id25)
alert('<?php echo $user?>');
</script>
Or whatever you want done with the value of $user; but that leads to
Fourth; remember that all the PHP in a page is run on the server before any of the JavaScript is run on the client. If you're expecting that PHP to only run if(name==id25) then you're forgetting that fact. Usually when PHP-supplied data is being inserted into JavaScript code, it's put into JavaScript variables (e.g., "var username='<?php echo $user?>';") and leave it for JavaScript to figure out what to do with it later (when it runs). The only way to get a PHP program to do anything in response to something that happened in JavaScript is for the JavaScript program to send a request to the server for the page that contains the PHP program.