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('register2.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, jo**@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.