Very strange problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shelly

    Very strange problem

    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 "passwordConfir m".

    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_passwordCon firm = $_POST['passwordConfir m'];
    echo "strlen(" . $ss_password . ") = " . strlen($ss_pass word) . "<br>";
    if (strlen($ss_pas sword) < 6) {
    echo "In strlen <br>";
    $_SESSION['MM_NewUserErro r'] = "Error: You need a password of at least
    six characters";
    $insertGoTo = "ssRegister.php ";
    } else if (strcmp($ss_pas sword, $ss_passwordCon firm)) {
    echo "In compare <br>";
    $_SESSION['MM_NewUserErro r'] = "Error: The Password, Confirm Password
    do not match";
    $insertGoTo = "ssRegister.php ";
    } ... more else if's ... {
    } else {
    ..... put it in the database
    $insertGoTo = "ssThankYou.htm l";
    }
    header(sprintf( "Location: %s", $insertGoTo));
    exit();
    }

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

    <?php
    if (isset($_SESSIO N['MM_NewUserErro r'])) {
    echo $_SESSION['MM_NewUserErro r'];
    unset($_SESSION['MM_NewUserErro r']);
    }
    ?>



  • Daniel Tryba

    #2
    Re: Very strange problem

    Shelly <sheldonlg.news @asap-consult.com> wrote:[color=blue]
    >
    > 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:[/color]
    [snip incomplete exmaple]

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

    Comment

    • Dinçer Akay

      #3
      Re: Very strange problem

      <?php

      $msg='';

      if($_SESSION['count_retry']<15){
      if(isset($_POST["Submit"])){
      if(strlen($_POS T['username'])<5){$msg.='Err or: You need a user name
      of at least six characters<br>' ;}
      if(strlen($_POS T['password'])<5){$msg.='Err or: You need a password
      of at least six characters<br>' ;}
      if($_POST['password']!=$_POST['passwordConfir m'] ){$msg.='Error: The
      Password, Confirm Password do not match';}

      if(empty($msg)) {
      header("Locatio n:ssThankYou.ht ml");
      exit;
      }else{
      $_SESSION['count_retry']++;
      }

      }

      }else{$msg='Reg istration 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="passwordC onfirm"><br>
      <input type="submit" name="Submit" value="Submit">
      </form>

      Comment

      • Shelly

        #4
        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
        server.

        Communication problem!!!

        Shelly

        "Dinçer Akay" <dincerakay2@gm ail.com> wrote in message
        news:1120332564 .337800.258650@ g47g2000cwa.goo glegroups.com.. .[color=blue]
        > <?php
        >
        > $msg='';
        >
        > if($_SESSION['count_retry']<15){
        > if(isset($_POST["Submit"])){
        > if(strlen($_POS T['username'])<5){$msg.='Err or: You need a user name
        > of at least six characters<br>' ;}
        > if(strlen($_POS T['password'])<5){$msg.='Err or: You need a password
        > of at least six characters<br>' ;}
        > if($_POST['password']!=$_POST['passwordConfir m'] ){$msg.='Error: The
        > Password, Confirm Password do not match';}
        >
        > if(empty($msg)) {
        > header("Locatio n:ssThankYou.ht ml");
        > exit;
        > }else{
        > $_SESSION['count_retry']++;
        > }
        >
        > }
        >
        > }else{$msg='Reg istration 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="passwordC onfirm"><br>
        > <input type="submit" name="Submit" value="Submit">
        > </form>
        >[/color]


        Comment

        Working...