PHP vars in JavaScript
Moderator: General Moderators
PHP vars in JavaScript
I just wonder, is it possible to use PHP variables in JavaScript in any way? I'm asking because I'm going to create a user registration form for a community in the future, and I want a JavaScript alert box to pop up if the username you wrote already exists. That way the registration would be faster. Anyway, is it possible?
you have PHP var like ... say a session var called uname
Code: Select all
<script language="javascript" type="text/javascript">
<!--
var popname = <?php echo $_SESSION['uname']; ?>
alert("hello "+popname);
//-->
</script>