PHP form

My client wants a Samples Request form that when an item is selected it will be added to a list. It would be sort of like a shopping cart but nothing is actually purchased so a shopping cart would be overkill. They just want whatever sample items are selected on the form to appear on a page and then when submitted that info is passed on to my client so they can ship the sample(s) to their prospective customer.

I have used FormMail PHP and am thinking that PHP could handle this type of scenario but have no idea how implement it. Where I'm lost is how to show the selected items before processing the form.
Who is Participating?
There are a couple of ways to show the selected items before processng the form.

1) on the form's "action" page, don't send the e-mail directly, only show the forms fields from the form ( ie. echo all the $_POST vars) , then, create a new form on that page that has all the $_POST vars in hidden form fields with a new form action, thus, this form will only have a "submit" button visible to the user, but contain all the information submitted in the original form as hidden fields. ON the subsequent action page, you can use the $_POST vards from this second form to contruct your mail and actually mail it.

2) On submit of you original form, you can write the form fields to a db. Then, on the action page, you can simply echo the $_POST vars and then have a button/link to a new page that reads the data from the db and compose an e-mail .

3) You can do everything on the same page by submitting the form back to itself. Then you just add some "markers" to the "action" link depending on which step in the process you are. In your code, you check for theis $_GET variable that you can append to the action link and only show/execute the relevant forms/code
The best way is to put the items in a Session:
1. Use a normal form to enter the request (preferrably using a method="post" in your form)
2. Pick up the data and put it in a session (eg array_push($_SESSION['samples'],$_POST['item']). This way everything is saved in an array and you can add as many items as you want
(3. If needed, display everything so the client can see what samples he requested)
4. Send everything (with a simple for/foreach-loop that puts everything in a mail)
fred_belangerAuthor Commented:
Thanks both of you for your suggestions. I definitely have enough info now to start digging in and figuring things out.  
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.