| | #1 |
| TNT Join Date: 2012 Location: florida
Posts: 65
Thanks: 19
Thanked 5 Times in 5 Posts
|
its a simple enough form, uses method="post" the issue is that i have several text inputs that need to all submit to "customer_comments" but when i name them all "customer_comments" only the final one ends up being seen in the database. im trying to do php to handle it but there seems to be issues <? $customer_comment = ""; foreach($_POST['customer_comment'] as $value) { $customer_comment .= $value . ", "; } $customer_comment = substr($customer_comment, 0, -2); //to get rid of the final ", " echo $customer_comment; ?> right now, instead of posting customer comment,customer comment, customer comment it's just posting "Array" |
| |
| | #2 |
| QA Manager - I Hate Bugs! Join Date: 2007 Location: Sydney, Australia.
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post
|
Can you post the code from your initial form? The input filed names should be something like name="customer_comment[]" Also, I hope you are checking the return values for html and other injection hacks otherwise you will be in real trouble... |
| |
| The Following User Says Thank You to MarkLL For This Useful Post: |
| | #3 |
| TNT Join Date: 2012 Location: florida
Posts: 65
Thanks: 19
Thanked 5 Times in 5 Posts
|
the issue ended up being in the submission page that the form was linked to. I used this javascript instead. <div class="fieldContainer"> <p> Beam Size:<input type="text" name="beam" id="beam" onKeyUp="return bar()" /></div> <p> <div class="fieldContainer"> <select name="beamm" id="beamm" onChange="return bar()"><option label="Select one">Feet/Meters</option><option label="feet" value="feet">Feet</option><option label="meter">Meters</option></select> </p> </p> </div> <div class="fieldContainer"> <p> Mast Height:<input type="text" name="mast" id="mast" onKeyUp="return bar()"/></p></div> <div class="fieldContainer"><p><select name="mastm" id="mastm" onChange="return bar()"><option label="Select one">Feet/Meters</option><option label="feet" value="feet">Feet</option><option label="meter">Meters</option></select> </p> </div> <div class="fieldContainer"> <p> Towable Trailer:<select name="trailer" id="trailer" onChange="return bar()"><option label="Select one">Select one</option><option label="Yes" value="yes">Yes</option><option label="No" value="0">No</option><option label="Not Suitable" value="no">Not Suitable</option></select> </p> </div> <div class="fieldContainer"> <p>Overall Length:<input type="text" name="length" id="length" onKeyUp="return bar()" /></p></div> <div class="fieldContainer"><select name="lengthm" id="lengthm" onChange="return bar()"><option label="Select one">Feet/Meters</option><option label="feet" value="feet">Feet</option><option label="meter">Meters</option></select> <br /> </p> </div> <div class="fieldContainer"> <p>Overall Height:<input type="text" name="height" id="height" onKeyUp="return bar()" /></p></div> <div class="fieldContainer"><select name="heightm" id="heightm" onChange="return bar()"><option label="Select one">Feet/Meters</option><option label="feet" value="feet">Feet</option><option label="meter">Meters</option></select> <br /> </p> </div> <div class="fieldContainer"> <p>Category:<select name="category" id="category" onChange="return bar()"><option label="Select one">Select one</option><option label="Power" value="power">Power</option><option label="Sail" value="sail">Sail</option></select> <br /> <textarea id="customer_comment" name="customer_comment" style="visibility:hidden"></textarea> </p> </div> <script language="javascript" type="text/javascript"> function bar() { document.getElementById('customer_comment').value = " beam: " + document.getElementById('beam').value + "" + " " + document.getElementById('beamm').value + "|" + " mast: " + document.getElementById('mast').value + "" + " " + document.getElementById('mastm').value + "|" + " trailer: " + document.getElementById('trailer').value + "|" + " length: " + document.getElementById('length').value + "" + " " + document.getElementById('lengthm').value + "|" + " height: " + document.getElementById('height').value + "" + " " + document.getElementById('heightm').value + "|" " category: " + document.getElementById('category').value + "|"; } </script> |
| |
| | #4 |
| Software Product Creator War Room Member Join Date: 2012 Location: NL => Thailand
Posts: 452
Thanks: 42
Thanked 164 Times in 93 Posts
Blog Entries: 5 |
this would have been the change to make it work probably: foreach($_POST['customer_comment'] as $value) to foreach($_POST['customer_comment'] as $key => $value) |
| Recurring Proven SEO Business Model Rent Out Your (Local) Sites and YT vids Give you AD Funnel Super Power! ADConnect.io - Lower CPC. Sky-Rocket Conversions!! | |
| |
| The Following User Says Thank You to SteveSRS For This Useful Post: |
| | #5 |
| HyperActive Warrior Join Date: 2012
Posts: 153
Thanks: 1
Thanked 7 Times in 7 Posts
|
Well An easy way to this is, just take all the comments in different variables like : $comment1 = $_POST['comment1']; $comment2 = $_POST['comment2']; $comment3 = $_POST['comment3']; and then join all of them under one variable $finalcomment = $comment1.$comment2.$comment3; All you need to do is post this variable into your table and you're done |
| |
| The Following User Says Thank You to boilingstocks For This Useful Post: |
|
| Bookmarks |
| Tags |
| column, database, fields, form, multiple |
| |