Running JavaScript in PHP file
<p>I made a simple login using JavaScript, but record the username in a PHP session.It's a simple web chat, so I want when the chat page is loaded the user to be forced to pick an username, but after that I want to store that info ina a PHP session and if the page is reloaded for some reason to do a check if $_SESSION['UserName'] is empty and if it's not to stop the script from executing again.I put my login JS in <code>&lt;body onload..&gt;</code> and the code looks like this:</p>

<pre>
&lt;body onload = "showUser(), showChat(), &lt;?php if ($_SESSION['UserName']==""){
{
  Login();
}?>">
</pre>

<p>I'm just learning now, so I gues I have some newb mistakes, like I'm almost sure that I'm not calling the <code>Login()</code> function right (it's JS function), but that's my strating point.Could anyone explain to me, how should I do the check properly and add the JS function in my PHP code?</p>

<p>P.S And I don't know if this really matter but if I remove the PHP code and leave liek this:</p>

<pre><code>&lt;body onload = "showUser(), showChat(),Login()"&gt;
</code></pre>

<p>My script is executed properly and I get everything that should be shown when the page is loaded, but when I add the PHP script and try to load the page I get blank page.I really wonder what's the reason for this too?</p>
