I have an html form with a field for name, email, and comment. If you are not logged in you have to type these things in manually. They are then stored in javascript variables and run through ajax (which I did not bother to include). The PHP if statement below is supposed to detect if you are logged in, then replace the name and email variables with your username and email automatically (which are stored in PHP variables). The way I have it now does not work at all. How can I replace the value of the javascript variables with the contents of a PHP variable using an if-statement?
<script type='text/javascript'> $('.bt-add-com').click(function(){ var theCom = $('.the-new-com'); var theName = $('#name-com'); var theMail = $('#mail-com'); <?php if($username && $userid) : ?> var theName = "<?php $username; ?>"; var theMail = "<?php $email; ?>"; <?php endif; ?> </script>