View Full Version : Event Registration Form Issue

05-28-2011, 02:29 AM
Hey All!

Well, here I am at PHP Freaks mercy again lol. I love this website and everyone here is always so helpful so let's get to my most recent issue.

I am developing a pretty simple event registration form, which would be pretty easy in most respects. It will have the following pretty standard fields.

Number of people attending: (drop down with 1-10)
Alternate Phone

There will be a few other fields but they aren't relevant. Basically the first field "Number of people attending (drop down 1-10)" will have to create a section with the following fields above for each person's information. If there are 3 people attending then it will need to have 3 sections of all those fields for each person.

Making the page dynamically generate those sections on-the-fly when the user selects "3" for example is the first issue I am having. The other issue I am having is how would I handle the information dynamically within the PHP. If there was just one person it would be easy because I could just reference those fields.

One solution I have for the second problem that I have some experience with is naming the fields name[] for example. But I still don't have a complete grasp on how to make that fix my problem. I've tried googling for hours but have had no luck, which may be because I'm not sure how to phrase the problem maybe.

Any help!

05-28-2011, 09:38 AM
This is Coding Forums not PHP Freaks :D

Anyway yes you have the right idea, use name[] in your html form and then loop through the resulting array in PHP. Here's a tip on how to work with the form data if you're not sure how it's been generated on the PHP side. Add echo "<pre>".print_r($_POST,true)."</pre>"; to the top of the script and you'll then be able to see what the format of your $_POST array is. Knowing this will help you figure out how to loop through it.