kujina Posted January 16, 2008 Share Posted January 16, 2008 Hi I'm very new to php, I will buy a good book on it soon (recommendations?) I have been asked to put up a contact form for a school website. It needs to go live very soon (wednesday afternoon) so I would appreciate any help. I'm using the contact form here http://www.ibdhost.com/contact/ On the following drop down list I'm going to have it start on "Please Select a Subject" and then require the user to select one of the subsequent options: Questions/feedback Relating to:<br /> <select name="attn" size="1"> <option value=" select ">Please Select a Subject </option> <option value=" My Childs Education ">My Childs Education </option> <option value=" Student Welfare ">Student Welfare </option> <option value=" Communications ">Communications </option> <option value=" General Education Issues ">General Education Issues </option> </select> What do I need to do to make it so a user must not have "Please Select a Subject" selected? This is what I have so far. http://www.chalvedon.com/contact/contact.php ...Thanks... Link to comment https://forums.phpfreaks.com/topic/86233-solved-drop-down-selection-required-selections-help/ Share on other sites More sharing options...
revraz Posted January 16, 2008 Share Posted January 16, 2008 Do a IF statement and make sure $_POST['attn'] is not empty. Remove the spaces around the values as well. Link to comment https://forums.phpfreaks.com/topic/86233-solved-drop-down-selection-required-selections-help/#findComment-440464 Share on other sites More sharing options...
Ell20 Posted January 16, 2008 Share Posted January 16, 2008 I think this is what you mean? Try this: Questions/feedback Relating to:<br /> <select name="attn" size="1"> <option value="" disabled="disabled">Please Select a Subject</option> <option value=" My Childs Education ">My Childs Education </option> <option value=" Student Welfare ">Student Welfare </option> <option value=" Communications ">Communications </option> <option value=" General Education Issues ">General Education Issues </option> </select> Link to comment https://forums.phpfreaks.com/topic/86233-solved-drop-down-selection-required-selections-help/#findComment-440465 Share on other sites More sharing options...
Ken2k7 Posted January 16, 2008 Share Posted January 16, 2008 In the PHP, you can check using: if ($_POST['attn'] != " select "){ // do something here } Link to comment https://forums.phpfreaks.com/topic/86233-solved-drop-down-selection-required-selections-help/#findComment-440478 Share on other sites More sharing options...
priti Posted January 16, 2008 Share Posted January 16, 2008 Hi, Referring Questions/feedback Relating to:<br /> <select name="attn" size="1"> <option value=" select ">Please Select a Subject </option> <option value=" My Childs Education ">My Childs Education </option> <option value=" Student Welfare ">Student Welfare </option> <option value=" Communications ">Communications </option> <option value=" General Education Issues ">General Education Issues </option> </select> <option value=" select ">Please Select a Subject </option> change this to <option value="">Please Select a Subject </option> When you will post check trim($_POST['attn']) != ''. i.e attn should not be empty. regards Link to comment https://forums.phpfreaks.com/topic/86233-solved-drop-down-selection-required-selections-help/#findComment-440619 Share on other sites More sharing options...
kujina Posted January 16, 2008 Author Share Posted January 16, 2008 Hi Thanks for all the responses, this looks like a nice active forum! I basically dont know anything about php or any other scripting language, so I'm quite happy that I'm coping so far! I managed to get it working how I wanted, I used the following in contact.php Questions/feedback Relating to:<br /> <select name="attn" size="1"> <option value="">Please Select a Subject</option> <option value="My Childs Education">My Childs Education </option> <option value="Student Welfare">Student Welfare </option> <option value="Communications">Communications </option> <option value="General Education Issues">General Education Issues </option> </select> And I used the following in sendeail.php if(empty($attn)) { echo "<h2>Use Back & Select a question subject from the drop down menu</h2>\n"; $badinput = "<h2>Message was NOT submitted</h2>\n"; echo $badinput; die ("← Go back!"); } My mistake when experimented with it originally, was having a space between the empty quotes " " Thanks a lot everyone Link to comment https://forums.phpfreaks.com/topic/86233-solved-drop-down-selection-required-selections-help/#findComment-440728 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.