Can anyone offer a solution to a POST'ing problem please

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

    Can anyone offer a solution to a POST'ing problem please

    Hi all,

    I have a page named register.php, which is a form for collecting user data.
    As an example:
    - I have the fields Name, Surname, email.
    - In the <form> tag I have action =""
    - The page register.php has a condition
    if (isset($_POST['submit'])) {
    include('regist er2.php');
    }
    - the file register2.php does the error checking etc.
    - I am using sessions and they do work as I can get this page to work using
    various methods except for when I display the errors on the same page.

    The Problem:
    If a user John, Smith, john@smith.com fills in the form but leaves the
    surname blank. A message is displayed on the same page telling him the
    surname is required. If, however, he changes the first name to Johnny but
    still leaves the surname blank, clicking the submit button displays the
    surname error, and his first entry (John) in the name field, clicking the
    submit button again, with the surname blank, displays the error message but
    displays Johhny in the name field. Subsequent submits with the missing
    surname makes the first name alternate between John and Johnny.
    I have an understanding of the POST process and know that I can display a
    different page for the error message, with a 'return' button/anchor to
    resolve this issue but does anyone know of a solution, using the above
    setup, whereby I can display the error on the same page and prevent the user
    variables from swapping It's a big question but TIA.



  • Mr Mint

    #2
    Re: Can anyone offer a solution to a POST'ing problem please

    Oops, I was too impatient/fustrated. I have managed to find a solution. I
    don't know if it is the best one.
    For anyone who is interested: I redirected to register.php on an error,
    which solved the displaying of information in the text fields.
    A new problem arose which is that I could not display error messages as my
    errors work by each error that occurs assigning a value to the variable
    $error. A function is called at the end of the register2 which formats and
    displays the error i.e. error_box($erro r). Using the redirect made me think
    I had messed up the error handling but I session registered $error and all
    is well.

    Sorry for the monologue guys/girls but I have just surface after a year of
    programming.
    "Mr Mint" <minty@home.com > wrote in message
    news:3f90439f$0 $373$afc38c87@a uth.uk.news.eas ynet.net...[color=blue]
    > Hi all,
    >
    > I have a page named register.php, which is a form for collecting user[/color]
    data.[color=blue]
    > As an example:
    > - I have the fields Name, Surname, email.
    > - In the <form> tag I have action =""
    > - The page register.php has a condition
    > if (isset($_POST['submit'])) {
    > include('regist er2.php');
    > }
    > - the file register2.php does the error checking etc.
    > - I am using sessions and they do work as I can get this page to work[/color]
    using[color=blue]
    > various methods except for when I display the errors on the same page.
    >
    > The Problem:
    > If a user John, Smith, john@smith.com fills in the form but leaves the
    > surname blank. A message is displayed on the same page telling him the
    > surname is required. If, however, he changes the first name to Johnny but
    > still leaves the surname blank, clicking the submit button displays the
    > surname error, and his first entry (John) in the name field, clicking the
    > submit button again, with the surname blank, displays the error message[/color]
    but[color=blue]
    > displays Johhny in the name field. Subsequent submits with the missing
    > surname makes the first name alternate between John and Johnny.
    > I have an understanding of the POST process and know that I can display a
    > different page for the error message, with a 'return' button/anchor to
    > resolve this issue but does anyone know of a solution, using the above
    > setup, whereby I can display the error on the same page and prevent the[/color]
    user[color=blue]
    > variables from swapping It's a big question but TIA.
    >
    >
    >[/color]


    Comment

    Working...