RE: [Phplib-users] How to make a multipage data submition... ?
Brought to you by:
nhruby,
richardarcher
|
From: Benjamin H. <ho...@eu...> - 2002-10-30 10:49:10
|
hmm i got one problem
I have obe problem
how save the submitted data in an object ?
could someone please give an example ?
thanks
Benjamin
> ----------
> From: Michael Chaney[SMTP:mdc...@mi...]
> Sent: 29 October 2002 18:28
> To: Benjamin Hoft
> Cc: 'php...@li...'
> Subject: Re: [Phplib-users] How to make a multipage data submition... ?
>
> On Tue, Oct 29, 2002 at 01:52:29PM +0100, Benjamin Hoft wrote:
> > Hi
> > my problem is, that i have to make a page
> > on which i can go to serveral other pages and submit each entered data to the next page which is insertet on the dbase on the last page.
> >
> > But how can i do this ??
> > any suggestions or Ideas ?
> >
> >
> > The pages eg. must look like this
> >
> > 1. page
> > addressdata input fields
> > 2. page
> > firm selection
> > 3. page
> > other stuff selection
> > 4. page
> > enter the given data into dbase
>
> The reasonable way to do it is to store the data in the session,
> probably best in an array or object. Put all the pages into a single
> .php file, and keep track of which "page" the user is on. At the bottom
> of the page, put a "Next" and a "Previous" button.
>
> Your program logic looks like this:
>
> if (is_numeric($_REQUEST['page'])) $page=$_REQUEST['page'];
> if (!$page) $page=0;
>
> { store form values in session }
>
> if ($_REQUEST['submit']=='Previous' && $page>1) {
> $page--;
> } elseif ($page<$last_page) {
> { validate form values }
> $page++;
> }
>
> if ($page==1) {
> # show page 1
> } elseif ($page==2) {
> # show page 2
> etc.
>
> Your last page might post to another file for the final submission.
> Given how users are, you should put your "Previous" button at the top,
> also. Obviously, the code is a bit more complex than this, but I think
> you can get the general flow of it.
>
> This way, they'll get to move back and forth without causing trouble.
> They can always force it to skip pages, but you can always set flags to
> make sure each page's data base been validated and don't allow the final
> page if all pages haven't been validated.
>
> I did an application like this earlier this year, and if I ever get
> around to writing the advanced PHP book this will probably be a chapter.
>
> Michael
> --
> Michael Darrin Chaney
> mdc...@mi...
> http://www.michaelchaney.com/
>
|