PHP - How to display this Server Error in a decent way
<p>Here is my login PHP code.</p>

<pre><code>&lt;?php // rnlogin.php
include_once 'rnheader.php';
echo "&lt;h3&gt;Member Log in&lt;/h3&gt;";
$error = $user = $pass = "";

if (isset($_POST['user']))
{
 $user = sanitizeString($_POST['user']);
 $pass = sanitizeString($_POST['pass']);

 if ($user == "" || $pass == "")
 {
  $error = "Not all fields were entered&lt;br /&gt;";
 }
 else
 {
  $query = "SELECT user,pass FROM rnmembers
      WHERE user='$user' AND pass='$pass'";

  if (mysql_num_rows(queryMysql($query)) == 0)
  {
   $error = "Username/Password invalid&lt;br /&gt;";
  }
  else
  {
   $_SESSION['user'] = $user;
   $_SESSION['pass'] = $pass;
   die("You are now logged in. Please
      &lt;a href='rnmembers.php?view=$user'&gt;click here&lt;/a&gt;.");
  }
 }
}

echo &lt;&lt;&lt;_END
&lt;form method='post' action='rnlogin.php'&gt;$error
Username &lt;input type='text' maxlength='16' name='user'
 value='$user' /&gt;&lt;br /&gt;
Password &lt;input type='password' maxlength='16' name='pass'
 value='$pass' /&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
&lt;input type='submit' value='Login' /&gt;
&lt;/form&gt;
_END;
?&gt;
</code></pre>

<p>As you can see the error message is printed with echo.
Is there a way that I can put this error message in a control  and display it only if there is error?</p>

<p>It sounds like I have to combine PHP with JavaScript?</p>

<p>The following code is used by Gmail to display error message.
It works even if JavaScript is turned off.
In other words, they use some techniques independent of JS.</p>

<p>Any idea, how I can do similar thing here?</p>

<pre><code>&lt;code&gt;
                &lt;td align="left"&gt;
                  &lt;div id="errormsg_0_Passwd" class="errormsg"&gt;
                  The username or password you entered is incorrect.
                  [&lt;a target="_blank" name="helpLink" href="http://www.google.com/support/accounts/bin/answer.py?answer=27444&amp;amp;hl=en&amp;amp;ctx=ch_ServiceLoginAuth&amp;amp;p=mail"&gt;?&lt;/a&gt;]
                  &lt;/div&gt;
                  &lt;/td&gt;
&lt;/code&gt;
</code></pre>

<p>Thank you</p>
