Very strange problem

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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?


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));

In the html area I have included in the proper place:

    if (isset($_SESSION['MM_NewUserError'])) {
       echo $_SESSION['MM_NewUserError'];

Re: Very strange problem

Quoted text here. Click to load it
[snip incomplete exmaple]

Please provide a simple, selfcontained fully "working" example.

Re: Very strange problem



        if(strlen($_POST['username'])<5){$msg.='Error:  You need a user name
of at least six characters<br>';}
        if(strlen($_POST['password'])<5){$msg.='Error:  You need a password
of at least six characters<br>';}
        if($_POST['password']!=$_POST['passwordConfirm'] ){$msg.='Error:  The
Password, Confirm Password do not match';}



}else{$msg='Registration disabled';}


<? if(!empty($msg)){ echo $msg; } ?>

<form name="form1" method="post" action="">
    username<input type="text" name="username" value="<? echo
$_POST['username']; ?>"><br>
    password<input type="password" name="password"><br>
    passwordConfirm<input type="password" name="passwordConfirm"><br>
    <input type="submit" name="Submit" value="Submit">

Re: Very strange problem

I found out the problem and it was ridiculously stupid.  I had created the  
page ssRegister.php.  I do all the php and my daughter does all the rest of  
the "pretty" stuff.  Well, without my knowing it she used the ssRegister.php  
as index.php.  So, although I was making changes locally to ssRegister.php  
and pushing them to the server, that was not the code that was run on the  

Communication problem!!!


Quoted text here. Click to load it

Site Timeline