spacepoet Posted November 30, 2011 Share Posted November 30, 2011 Hello: I want to create a feedback form that will allow a user to select from 30 or so items on a page, and send the data to an email address. I think it's something like a shopping cart but without a need to process a payment. I want to list items (like a soccer ball, a basket ball, etc.) and allow the user to select the size of the ball, the color, the number of balls, etc. I want the user to be able to select 1 item or many items. Once they are done, they would hit submit, and the data would get sent to an email address. Do I need to use a session to do this? I was trying to work with this code: <?php session_start(); session_register('product'); session_register('amount'); $_SESSION['product'] = $_POST['product']; $_SESSION['amount'] = $_POST['amount']; //SEND THE EMAIL CODE HERE ???? ?> <form method="post" action=""> <input type="text" size="10" name="product"><br /> <input type="text" size="10" name="amount"><br /> <input type="submit" value="Finish"> </form> But I'm pretty sure I'm not in the ballpark on how to do this. Anyone have any ideas? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/252099-feedback-form-for-multiple-items/ Share on other sites More sharing options...
joel24 Posted November 30, 2011 Share Posted November 30, 2011 if the form is on a single page and not requiring a login, you don't need a session... just <?php if (isset($_POST['form'])) { #send the email mail(); } ?> <form> <input type='checkbox' name='products' value='productID1'/> Product 1 <br/> <input type='checkbox' name='products' value='productID2'/> Product 2 <br/> <input type='submit' name='form' value='Submit' /> Quote Link to comment https://forums.phpfreaks.com/topic/252099-feedback-form-for-multiple-items/#findComment-1292526 Share on other sites More sharing options...
spacepoet Posted November 30, 2011 Author Share Posted November 30, 2011 Hi: Ah! Yes, this makes sense - I think I was overlooking the obvious a bit. OK, but what if I want to have the user be able to select items and attributes of items. I want to add a few SELECT dropdown menus to the products as well and send them in the email. Meaning if they are ordering T-Shirts - I want them to enter the amount, the color, and the size. And if they want to add pants to the order, let them chose the color, size, amount, and have all the data emailed as one email when they hit submit. Any ideas? This is why I thought they would need a SESSION or something like that. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/252099-feedback-form-for-multiple-items/#findComment-1292720 Share on other sites More sharing options...
joel24 Posted November 30, 2011 Share Posted November 30, 2011 <?php if (isset($_POST['form'])) { #send the email $order=''; $order.=(isset($_POST['shirts']))?"shirt: {$_POST['shirts']} - size:{$_POST['shirtSize']} - colour: etc etc":''; mail('[email protected]','New Order',$order); } ?> <form method='POST'> <h1>Shirts</h1> <select name='shirts'> <option value=''>Please Select</option> <option value='shift2'>Shirt 2</option> <option value='shift3'>Shirt 3</option> </select><br/> <h3>Size</h3> <select name='shirtSize'> <option value=''>Please Select</option> <option value='small'>Small</option> <option value='large'>Large</option> </select> <input type='submit' name='form' value='Submit' /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/252099-feedback-form-for-multiple-items/#findComment-1292801 Share on other sites More sharing options...
spacepoet Posted December 1, 2011 Author Share Posted December 1, 2011 Hi: Thanks! That looks much easier than I was making it out to be. I will play around with your code and see how I do. Thanks very much for the help! Quote Link to comment https://forums.phpfreaks.com/topic/252099-feedback-form-for-multiple-items/#findComment-1292852 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.