Page 1 of 1

Need help redirecting radio buttons and forum submit buttons

Posted: Mon Apr 23, 2012 11:10 pm
by pat_004
Need help redirecting radio buttons and forum submit buttons



Hey guys. So im extremely excited to now be apart of this community. Im fairly new to php, I have been coding with it for about 5 months and I quickly realized that If I was going to be any good at this that I would need to get plugged into a community. So I here to learn and contribute.

Ok so I have been working with a small project for a few weeks now and I have a few questions that I need some help on.

First off I would like to show you my diagram and then explain what im trying to accomplish. Im not asking for you the full blown code, I just need some answers to some very specific questions, I just thought I would post my diagram so you would have a good idea of what im trying to do so that you can accurately answer my question.

Image

Ok, so what I have done is built 4 radio choices in the index.php page along with a submit button, and what im trying to do is when a person chooses item_1 it takes them to a different page when they hit submit. Then what happens is say that when they chose item_1 it takes them to item_1.php, and inside item_1.php they will need to fill out some very basic information and hit submit. When they hit submit, the information needs to print on the final page, but the user needs to be taken to the next page for more information, and so on till they reach the final page. I would also like to add that im using a basic html form for the information to be added into..

My first question is how do I get my radio boxes to redirect to a page based on the answer given. So when I chose item_1 it goes to item_1.php and item_2 goes to item_2.php and so on..

my second question is, when I submit the information I filled out, how do I get the information to print on the final page, but then send the user to the next page for more information..



Like I said, im not asking you to do it all for me, Im just looking for a bit guidance from you guys.

Thanks guys for all your help!

Re: Need help redirecting radio buttons and forum submit but

Posted: Tue Apr 24, 2012 4:31 am
by requinix
1. Do you have your heart set on using different PHP files for each option? What are these options for? Are they completely different things or are they similar but with some differences? Or you can answer a different question: how much copy/pasting are you going to be doing for these four sets of files?

2. Hidden fields in forms is a bit harder to manage than session but they are the "perfect" solution. Makes sense particularly if you're splitting the form up into multiple pages instead of into multiple steps. All the information in the previous pages is stored in the form and every subsequent page adds to it. At the very end all you have to do is look at $_POST.
Sessions are probably a more common solution but they have some flaws that have to be worked around. Most notably, a user can only have one of these forms open at a time. This might be a reasonable assumption for the form but I say it's not worth it. Each page's data gets pushed into the session and at the very end you look at $_POST for the previous page's data and $_SESSION for the earlier pages'.

Re: Need help redirecting radio buttons and forum submit but

Posted: Tue Apr 24, 2012 11:32 am
by pickle
1) I'm with ~requinix that the ideal solution wouldn't be separate files for each form. You could have some code on your index.php that basically says: "If the form was submitted and $_POST['item'] = 1, then show the form for item 1, if the form was submitted and $_POST['item'] = 2, then show the form for item2, and so on.

2) Hidden form fields are probably the easiest solution.