By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 992 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.

Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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($error). 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" <mi***@home.com> wrote in message
news:3f*********************@auth.uk.news.easynet. net...
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.

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.