Re: keeping fields moving forward

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

 



Mike Ryan wrote:
I am creating a series of forms that collect information this covers 3
screens before I want to write it out to the database.  when I go from one
screen to the next I have tried hidden and readonly input boxes but the data
in the hidden and readonly fields from screen one do not make it to the
final page.

Is there a way to get the data from page one without letting the users
modify the information.  I guess I could write the data to the database but
how do I find the record number of the data I just wrote so that I can
update the information, will php tell me the record number? I am using php
5.2.1 and mysql 5.x


I'd write a class to handle the submissions; I pretty much always do this with forms. Instantiate the object on the first submit, populate with whatever from form 1, do your validation, store the object in the session and display form 2. Repeat.

You could give the class methods to handle setting each field and validation methods for each form. When all is done, call persist() and you're done.

Just remember to include() your class file before calling session_start().

As an aside, whenever i'm displaying a form i instantiate the class first. This way, my form markup can have, eg:

<input type="text" name="foo" value="<?= my_class->getFoo() ?>" />

so that on the first pass the empty object returns NULL. When i want to re-display the form (because there was an error somewhere) the already-populated vars are written back to the form.

brian

--
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