Call Javascript function from within PHP block
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/1045845/how-to-call-a-javascript-function-from-php">How to call a JavaScript function from PHP?</a>  </p>
</blockquote>



<p>I'm working on a project for school, and I'm struggling with the login page. In my PHP code, if the user enters an incorrect username or password, I want to call a Javascript function that displays a message and briefly changes the background colour where the message is shown. Here are my JS and PHP code blocks:</p>

<pre><code>&lt;script&gt;
var flashContent = function () {
document.getElementById("outputlogin").style.backgroundColor = "#ffff00";
document.getElementById("outputlogin").innerHTML = "Incorrect login.";
function proxy() {
    updateColor(0);
}
setTimeout(proxy, 50);
}

var updateColor = function (newColor) {
var hexColor = newColor.toString(16);
if (hexColor.length &lt; 2)
    hexColor = "0" + hexColor;
var colorString = "#ffff" + hexColor;

document.getElementById("outputlogin").style.backgroundColor = colorString;

function proxy() {
    updateColor(newColor);
}

if (newColor &lt; 255) {
    newColor = newColor + 5;
    setTimeout(proxy, 50);
}
}
&lt;/script&gt;

&lt;?php
$username = $_POST['username'];
$password = $_POST['password'];

if(($username == "Ben") &amp;&amp; ($password == "thepassword")){
//echo "SUCCESS";
session_start();
$_SESSION['bensedmgallerysesh'] = session_id();

header("Location:../index.php");

}else{
if($username != "" &amp;&amp; $password != ""){
    javascript:flashContent();
}
}
?&gt;
</code></pre>

<p>Right now, after hitting the login button, I get the error message:</p>

<p>Fatal error: Call to undefined function flashContent()</p>

<p>How do I fix this?</p>
