Hello All, I have a form that is written in PHP which has dropdown lists. These are optional for the customer to fill out. They can request up to 4 items in each category, so if they choose 1 item, the remainder of the items should not show up in their confirmation e-mail nor should it show up in my e-mail. The problem is that when I receive the e-mail of the requested information, the list of dropdown items are shown, even if they didn't request any of the items. I am not sure how to tell the script to not print/echo the information on the form if there is nothing selected. It works okay, but there is too much chance for error on filling the order if there are blank areas repeating. Below is a link to the script, obviously, I'm new at this so there is probably a much better way of organizing the dropdown information... http://www.countymaterials.com/thinOrderForm.php Below is part of what I'm getting back in my e-mail confirmation... NOTE: The part I don't want to show up is the "Heritage Colors: Choice 2" since there was nothing selected for this. Any help is much appreciated!! Thanks! ============================================ Thanks for your order! CONTACT INFORMATION ------------------------------ Your Name: test Your E-Mail: test@test.com Company: test Occupation: test Address: sssss City: ssss State: WY Zip: 55555 Phone: 111-111-1111 Fax: ORDER SUMMARY --------------------- Heritage Colors, Choice 1: Black Walnut Size Heritage: 8x16 Texture Heritage: Rough Estate Quantity Heritage: 12 Sample Type Heritage: Loose Brick --------------------- Heritage Colors, Choice 2: Size Heritage: Texture Heritage: Quantity Heritage: Sample Type Heritage:
You need to wrap a php IF statement around $msg .= "Heritage Colors, Choice 2: $colHer1_1\n\n"; $msg .= "Size Heritage: $sizeHer1_1\n\n"; $msg .= "Texture Heritage: $textHer1_1\n\n"; $msg .= "Quantity Heritage: $quantityHer1_1\n\n"; $msg .= "Sample Type Heritage: $sampletypeHer1_1\n\n\n"; $msg .= "---------------------\n\n\n"; That specifies if colHer1_2 = "" then echo something blank, else echo $msg .= "Heritage Colors, Choice 2: $colHer1_1\n\n"; $msg .= "Size Heritage: $sizeHer1_1\n\n"; $msg .= "Texture Heritage: $textHer1_1\n\n"; $msg .= "Quantity Heritage: $quantityHer1_1\n\n"; $msg .= "Sample Type Heritage: $sampletypeHer1_1\n\n\n"; $msg .= "---------------------\n\n\n"; something to that effect
I tried something to that effect, but am not getting positive results. I'm sure this is being made much more difficult than it needs to be! ... Added this statement right below last $msg .= //TEST - should tell the form to print info if entered by customer, if no selection to the dropdown lists, then nothing should print if ($colHer1_2=="option value='' "){ echo "Heritage Colors, Choice 2: $colHer1_2" } else ($colHer1_2=="option selected='selected' ") { echo "" }
That looks a little backwards to me, also if your adding this to the end then all msg's above it will still be parsed. Reverse what you have, and put it around the actual code, you may need to use <?php ?>
Just to follow up on my dilemma, I really do want to figure this out and understand it, I'm afraid the problem is how I word the dropdown in the code. The way it's being called isn't a true/false kind of statement. Since it has a selection of nothing (listed as "option selected='selected'") really, that would still make it true, yes? But I need it to tell me if someone makes a selection outside of what is the default, then it should print it on the e-mail and onscreen confirmation. This is what I have so far, added above the $msg. area, the link is http://www.countymaterials.com/test_dropdown.phps if ($colHer1_2=="option selected='selected'") { echo""; } else { echo "Heritage Colors, Choice 2: $colHer1_2"'; } Any thoughts on what could still be the problem? Thanks!