I have come across a strange problem. I am setting up a registration screen
with username, password, confirm password, and a couple of other things.
The submit button is named "Submit". The others are named "username",
"password", and "passwordConfirm".
The problem is that when I enter a username and a password of 5 characters
with nothing in the passwordConfirm field, I do not get the diagnostic echo
messages that I have inserted. Also, the error message is not that I need
six characters, but that the password and passwordConfirm do not match. If
I then put in the password again, also with an empty confirm password, on
that form with the single message, then the diagnostic messages appear.
Previously, when there were no diagnostic echos, the second attempt showed
the length message. (The page is, of course, ssRegister.php).
Any ideas? This is driving me crazy.
1 - Why on the first click of "Submit" doesn't it present the diagnostics?
It MUST enter there because it DOES print out an error message.
2 - Why is it printing out the wrong error message?
Shelly
The guts of my code goes something like this:
if (isset($_POST["Submit"])) {
$ss_username = $_POST['username'];
$ss_password = $_POST['password'];
$ss_passwordConfirm = $_POST['passwordConfirm'];
echo "strlen(" . $ss_password . ") = " . strlen($ss_password) . "<br>";
if (strlen($ss_password) < 6) {
echo "In strlen <br>";
$_SESSION['MM_NewUserError'] = "Error: You need a password of at least
six characters";
$insertGoTo = "ssRegister.php";
} else if (strcmp($ss_password, $ss_passwordConfirm)) {
echo "In compare <br>";
$_SESSION['MM_NewUserError'] = "Error: The Password, Confirm Password
do not match";
$insertGoTo = "ssRegister.php";
} ... more else if's ... {
} else {
..... put it in the database
$insertGoTo = "ssThankYou.html";
}
header(sprintf("Location: %s", $insertGoTo));
exit();
}
In the html area I have included in the proper place:
<?php
if (isset($_SESSION['MM_NewUserError'])) {
echo $_SESSION['MM_NewUserError'];
unset($_SESSION['MM_NewUserError']);
}
?>