RMDesign Posted April 12, 2011 Share Posted April 12, 2011 Hello, I am very very new to PHP and have created a form that changes depending on a selection option. The website is here http://www.rmdesignstudio.com.au/wraptinprint/quotes.php and the PHP is all on the quotes.php page. The form sends to the email but when you fill in one form (example: Business Cards) the form sends, but along with all the entered fields the email also includes all the fields in all the hidden forms that werent filled in. I believe it is because they are drop down boxes and it is sending the first option in the list which happens to be "-----Please Select-----" Is there something I should be doing to my selection input field for this not to show up? Otherwise is there something I need to add to my PHP so it checks for the fields being filled in? I dont know how to add my code to this post, so if you could either show me or view my code via view source that would be awesome. Quote Link to comment https://forums.phpfreaks.com/topic/233463-help-php-form-sending-blank-inputs-to-email/ Share on other sites More sharing options...
dcro2 Posted April 12, 2011 Share Posted April 12, 2011 If you don't want it sending you "-----Please Select-----" then disable that option. <option disabled="disabled">-----Please Select-----</option> Quote Link to comment https://forums.phpfreaks.com/topic/233463-help-php-form-sending-blank-inputs-to-email/#findComment-1200465 Share on other sites More sharing options...
RMDesign Posted April 13, 2011 Author Share Posted April 13, 2011 Thanks for the reply, unfortunately this just made the default option another thing which also automatically shows up in the email What i want is for the user to choose whether they want to input details into these fields or leave them at the ----please select--- option. if left at the ----please select----- option i want that input to be discluded from the email Is there a way I can do this? Quote Link to comment https://forums.phpfreaks.com/topic/233463-help-php-form-sending-blank-inputs-to-email/#findComment-1200993 Share on other sites More sharing options...
codebyren Posted April 13, 2011 Share Posted April 13, 2011 When you're capturing the data that the user submitted, just ignore the input if nothing was selected. For example: Print Quantity: <select name="quantity2"> <option value="">--Please Select--</option> <option value="500"></option> <option value="1000"></option> <option value="2500"></option> <option value="Other"></option> </select> You might notice the value="" on the "--Please Select--" option element. Then handle the post: <?php if (isset($_POST['quantity2']) && $_POST['quantity2'] != '') { // Add quantity to the email since it wasn't left blank } ?> Hope that puts you in the right direction. Quote Link to comment https://forums.phpfreaks.com/topic/233463-help-php-form-sending-blank-inputs-to-email/#findComment-1201031 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.