Alex,
as a general rule of thumb, try to do as much checking as you can with JavaScript. For those checks such as "is the field a valid date", "is the field numeric" and so on, it is much faster to check on the client, than to send the data back to the server and check it there. Probably the best way to do this is with an "onSubmit" clause on the <form>. Something like:

<form name='RegisterForm' action='register.php' method='post' onSubmit='return checkRegisterScreen(this)'>

Some things you cannot check on the client, for example does the value of the field already exist in a data store on the server. There are many ways in which you could check these fields. On of the easiest to understand ways would be to name your submit field something like "Register", and use code something like the following in register.php:

switch ($_POST['submit']) {
case "a";
processA();
break;
case "b";
processB();
break;
case "Register";
checkFormAndRedisplay();
break;
default;
processDefault();
break;
}

In the procedure checkFormAndRedisplay(), you can write code to check your fields, and the relationships between them, and then redisplay the form with appropriate error messages, and highlighting, to guide the end user to correct his errors.

Hope this helps. . . Fred

Alex Davis wrote:
Ok ... here is the sitituation... I am creating a registration form.
What I have so far works ... the user registers using this form and the
form calls another page that will check the validity of the data
(checking for username availability, etc...). If there is an error,
display the error and have the user GO BACK AND TRY AGAIN <----- This is
the problem I want to fix.

What I want to do is have the registration form, on submit, check the
data validity right then, if there is an error, redisplay the form with
an * next to the field that is incorrect. This way the user does not
have to go back and try again, it will be there in front of them.

Basically, have the form action call itself .... hince the recursion.

Any suggestion/examples?

Thanks,

-Alex



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to