Populate fields from Listbox
Posted on 2007-12-02
OK, I have a form in a php file.
The first field on the form is a listbox. THe user needs to select an entry from the list box.
Once the entry is selected, a query is run. THe results of the query are put into a "table" on the page.
THen the user fills in the rest of the form.
On completion of the entry, the user hits the submit button. The form then goes to a validation.php file.
If all passes the validation, the user then goes to a second page (second form) that gets more input.
Once that page is filled out and the user hits Submit, everything (all input data from both pages) is saved to a database. After the database is updated, the user then gets a printable page back (where the fields they inputted are merged into some text) that they can then print out.
I can get the List box field on page 1 filled using a while loop using results from a query.
I can get the form submit on page 1 to go to the Validation.php script using the "action=" for the form.
I can store the inputted data (via $_SESSION variables) so I can save to the database.
My problems are:
1. I can't figure out how to do an automatic data retrieve when the user has made a selection from the list box. And stay on the same page to continue data entry. I've read several previous solutions and one came close, but can't quite figure it out completely.
2. I'm not sure if the "header........." will send the user to the second page from the validation.php script.
I need to be able to go from the Validation.php to the second page. Or come back to the first page if the validation does not pass. As an alternative, I could come back to the first page with a variable that is set to TRUE (maybe) if the validation was successful or false if unsuccessful? THen decide whether to stay on the page or continue to the next page.
Depending on how good the answers are, there could be bonus points. So try and be complete. Remember, I'm fairly New to PHP.
Thanks in advance.