RE: Help: Suggestions for multi page form validation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Personally I would do as you suggest in 1. I would think your users would
get rather annoyed if they had gone through several form pages to be told at
the end of an error in form page1.

So, page2 validates page1 etc. I would assume that page2 already does some
processing of page1 anyway, as I believe you are adding the form values to
the session. You may want to think along the lines of adding to a string
variable for each validation exception and then passing that back to page1
which will display the string variable if it contains anything. If you want
the originally entered data to also appear in the form fields you will also
have to pass that data back to page1 and display it.

//This is pseudo code ;)
$str='<ul>';
Check form_field1
If (error)
  $str .= '<li>Field1 in error</li>';
Check form_field2
If (error)
  $str .= '<li>Field2 in error</li>';
$str .= "</ul>";
If (any errors found) {
  $location = "page1.php?err=$str&fld1=$field1.....";
  Header($location);}
else{
  // Store form values in session & continue
}

HTH
Graham

> -----Original Message-----
> From: Stuart Felenstein [mailto:stuart4m@xxxxxxxxx]
> Sent: 19 October 2004 08:51
> To: php-general@xxxxxxxxxxxxx
> Subject:  Help: Suggestions for multi page form validation
>
>
> I have a multi-page form that ends in the last page as
> a transaction to mysql.  In the transaction there are
> a number of steps, i.e.
>
> query1 = Insert into "..........
> run query1
> query2 = Insert into ".........
> run query 2
> query3 = Insert into "..........
> run query 3
>
> Then an if / else statement that checks if all queries
> were sucessful (commit) or else (rollback)
>
> I need to add server side validation
> So my thoughts are :
>
> 1- Do it on a page by page (form by form) basis,
> meaning user can't go past page1 if there are form
> error.  I'm just not sure in this case where the
> validation would go.  Since 1st page is set on submit
> to go to 2nd page. Would I put the validations on
> page/form2 and then it would print out errors
> directing back to form1 ?
>
> 2- Last page validation - waiting till the transaction
> page to do validation. Should I set this up as one
> block on top that checks all the submitted form
> values, or pepper throughout all the transactions ?
>
> Hope my question is clear and am open to  any
> suggestions or ideas.
>
> Thank you ,
> Stuart
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux