Keeping some selected options after submitting form

Code junkies hangout here

Moderators: ChrisThornett, LXF moderators

Keeping some selected options after submitting form

Postby guy13 » Fri Mar 28, 2014 11:26 am

Hi all,

Thanks in advance for any suggestions on the following:

I've created a php-page to add works from composers to CDs. It's a combination of two forms and looks like this:

1st form:
Composer : [drop down list] : Select

Some blank space

2nd form:
Title : [drop down list]
Track number : [empty field]
Work : [drop down list]
+ some other fields

Process button

After selecting a name in the first block (posting to $_SERVER["PHP_SELF"]) I stay on the same page and that name is shown in the blank space in between and the drop down lists are populated with only CD titles and works of the selected composer.

I can then select from the lists and enter other data in the other fields. Hitting the process button posts the data from the second block to another page which will eventually send everything to a table in a MySQL database.

After that I send myself back to the first page with header("Location: the_first_page.php")

So far so good, but upon returning I would like the composer, title and work to be preselected. Now I'm sent to a blank page and have to start from scratch. I think I've seen some solution involving testing $_POST['something'] against <option value> in a drop down list but I can't seem to make that work. My question is: is there a way to send $_POST['Title'] and $_POST['Work'] back to the first page somehow? Or is it better to split the two forms over seperate pages?

All help is welcome.
guy13
 
Posts: 47
Joined: Wed Apr 13, 2005 7:39 pm
Location: Belgium

Return to Programming

Who is online

Users browsing this forum: Bing [Bot] and 0 guests