I figured out there was an extra space between the first and last names in the session variable. It didn't show up on the screen because HTML ignores double spaces. Is there a way to trim out this extra space?
OK, I have a page where I want to check a form submitted signature with a session registered name. The two values need to be exactly equal for the signature to be valid.
The problem is, when they are exactly the same, I can't get a comparison to return TRUE!!!! Argh.
OK, the form variable is:
$_POST['amateurSignature']
and the Session variable is
$_SESSION['name']
For my test, the value in the session variable is 'JOHN SMITH' without quotes. The value of the post variable is 'JOHN SMITH' without quotes. I know this, because I can ouput both to the screen. I trimmed them as well. And when I output, I use surrounding characters to make sure there isn't an extra space before or after the name. The names are identical.
However, if I run:
$sign1 = $_POST['amateurSignature'];
$sign2 = $_SESISON['name'];
$sign3 = strcmp($sign1, $sign2);
Then $sign3 gets assigned a value of 1, instead of 0 (0 means they are equal).
Also, if I try the strcmp without assigning the values to variables, but using the $_ variables directly it still doesn't work.
Also, something like this returns false:
if ($_POST['amateurSignature'] == $_SESSION['name']) { ... }
when it should return true!!! Why can't I get a true comparison on this?
Any help? It's driving me crazy!?!?
NOTE: If I run a strlen function on each, I find the session variable is 1 character longer than the post variable, although they appear identical on the screen, and I have trimmed them both. ?????
Thanks,
Sledge