I can’t get CSS to apply to the function below. Is it because it’s a form or because it uses dl, dt, and dd tags?
Thanks in advance,
John
function show_loginform($disabled = false)
{
echo '<form name="login-form" id="login-form" method="post" action="./index.php">
<div class=\"logintitle\">Please login</div>
<dl class=\"usernamefield\">
<dt class=\"siteadd\"><label title="Username">Username: </label></dt>
<dd class=\"siteadd\"><input tabindex="1" accesskey="u" name="username" type="text" maxlength="30" id="username" /></dd>
</dl>
<dl class=\"siteadd\">
<dt class=\"siteadd\"><label title="Password">Password: </label></dt>
<dd class=\"siteadd\"><input tabindex="2" accesskey="p" name="password" type="password" maxlength="15" id="password" /></dd>
</dl>
<ul>
<li><a href="http://www...com/sandbox/register.php" title="Register">Register</a></li>
<li><a href="http://www...com/sandbox/lostpassword.php" title="Lost Password">Lost password?</a></li>
</ul>
<p class=\"siteadd\"><input tabindex="3" accesskey="l" type="submit" name="cmdlogin" value="Login" ';
if ($disabled == true)
{
echo 'disabled="disabled"';
}
echo ' /></p></form>';
}
You have an escaping error within your code. To show just an extract:
You use
'but then escape", which will lead to\"being printed out to the user. You don’t have to escape"when using'as main quotes. This could be the problem for your browser, not correctly identifying your divs and thereby not applying css.addendum:
when echo’ing large portions (as already mentioned it would be better to use a templating system, e.g. smarty), you can close and reopen your php tags for better reading:
and you can crash most syntax highlighters doing this btw 😉