sudeepk Posted June 5, 2010 Share Posted June 5, 2010 I have 17 form fields. I use $_post to get the variables. Please let me know how to stop the form being submitted if any form field is left blank. I tried but couldn't solve. Please help me. $name = $_POST["name"]; $email = $_POST["email"]; $ans1 = $_POST["ans1"]; $ans2 = $_POST["ans2"]; $ans3 = $_POST["ans3"]; $ans4 = $_POST["ans4"]; $ans5 = $_POST["ans5"]; $ans6 = $_POST["ans6"]; $ans7 = $_POST["ans7"]; $ans8 = $_POST["ans8"]; $ans9 = $_POST["ans9"]; $ans10 = $_POST["ans10"]; $ans11 = $_POST["ans11"]; $ans12 = $_POST["ans12"]; $ans13 = $_POST["ans13"]; $ans14 = $_POST["ans14"]; $ans15 = $_POST["ans15"]; $ans16 = $_POST["ans16"]; These are the variables. Quote Link to comment https://forums.phpfreaks.com/topic/203968-reject-empty-form-fields/ Share on other sites More sharing options...
Muffins Posted June 5, 2010 Share Posted June 5, 2010 if(!empty($name) && !empty($email)...) { //Submit form } else { //Produce error, redisplay form etc. } Quote Link to comment https://forums.phpfreaks.com/topic/203968-reject-empty-form-fields/#findComment-1068287 Share on other sites More sharing options...
GoneNowBye Posted June 5, 2010 Share Posted June 5, 2010 if its empty when submitted it wont be declared $_POST['empty_field'] that is. use isset($_POST['whatever']) instead true on existing if you dont have strict PHP on - then dont worrie Quote Link to comment https://forums.phpfreaks.com/topic/203968-reject-empty-form-fields/#findComment-1068288 Share on other sites More sharing options...
jskywalker Posted June 5, 2010 Share Posted June 5, 2010 I have 17 form fields. I use $_post to get the variables. Please let me know how to stop the form being submitted it any form field is left black. I tried but couldn't solve. Please help me. $name = $_POST["name"]; $email = $_POST["email"]; $ans1 = $_POST["ans1"]; ....... $ans14 = $_POST["ans14"]; $ans15 = $_POST["ans15"]; $ans16 = $_POST["ans16"]; These are the variables. i cannot blame you for your bad english, but there are 18 filelds mentioned... but that has nothing to do with the problem which is unclear because of the 3 or 4 obvious langage errors on 1 sentence... Quote Link to comment https://forums.phpfreaks.com/topic/203968-reject-empty-form-fields/#findComment-1068291 Share on other sites More sharing options...
sudeepk Posted June 5, 2010 Author Share Posted June 5, 2010 @jskywalker I understand your pain. Thanks for your concern regarding my language. I appreciate your effort in finding the mistakes(regardless of how noticeable they were). But yeah, you should work on your perception part. See! Other people could understand it even though it had mistakes. Being smart is not everything. @Muffins I think i tried the same. It dint seem to work. @HavokDelta6 I will try to put that to use. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/203968-reject-empty-form-fields/#findComment-1068304 Share on other sites More sharing options...
ignace Posted June 5, 2010 Share Posted June 5, 2010 @jskywalker I understand your pain. Thanks for your concern regarding my language. I appreciate your effort in finding the mistakes(regardless of how noticeable they were). But yeah, you should work on your perception part. See! Other people could understand it even though it had mistakes. Being smart is not everything. <irony>Yeah, jskywalker you don't have any people skills. You obviously need to work on that.</irony> Quote Link to comment https://forums.phpfreaks.com/topic/203968-reject-empty-form-fields/#findComment-1068316 Share on other sites More sharing options...
sudeepk Posted June 5, 2010 Author Share Posted June 5, 2010 @Muffins Yeah, i was doing it wrong placing it above the declared variables. It definitely worked. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/203968-reject-empty-form-fields/#findComment-1068326 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.