I’ve tried to various solutions to this problem, but nothing seems to be working. I know the stylesheet is kicking in, because other rules are in place.
EDIT
the .error style is attached but i’m now getting two echos of $error, one in red and one in black one line below it. the reference to rcheader contains no references to $error.
css:
.error{
color:#FF0000;
}
This is the entire php page:
<link type="text/css" href="stylesheet.css" rel="stylesheet" media="all" />
<?php // rclogin.php
include_once 'rcheader.php';
echo "<h3>Member Log in</h3>";
// $error="<span class='error'></span>";
$error = $user = $pass = "";
if (isset($_POST['user']))
{
$user = sanitizeString($_POST['user']);
$pass = sanitizeString($_POST['pass']);
if ($user == "" || $pass == "")
{
$error = 'Not all fields were entered correctly.<br />';
}
if(strlen($error)>0) {
echo '<span class="error">' . $error . '</span><br/>';
}
else
{
$query = "SELECT user,pass FROM rcmembers
WHERE user='$user' AND pass='$pass'";
if (mysql_num_rows(queryMysql($query)) == 0)
{
$error = "Username/Password invalid<br />";
}
else
{
$_SESSION['user'] = $user;
$_SESSION['pass'] = $pass;
die("You are now logged in. Please
<a href='rcmembers.php?view=$user'>click here</a>.");
}
}
}
echo <<<_END
<form method='post' action='rclogin.php'>$error
Username <input type='text' maxlength='16' name='user'
value='$user' /><br />
Password <input type='password' maxlength='16' name='pass'
value='$pass' /><br />
<input type='submit' value='Login' />
</form>
_END;
?>
The logic of your php code is the problem here:
You set the error message to be an empty string, and then you immediately have it spit out an empty error message, and THEN you run the check that populated the
$errorvariable?!?Remove
And modify this code to add the error-output logic:
** Keep in mind… ** when checking if a variable is an empty string, use
strlen($var)==0orempty($var)or check if$var==''the statement:if($var)is looking for a boolean TRUE/FALSE