Movies32 Posted April 12, 2013 Share Posted April 12, 2013 I'm trying to complete an assignment that has to validate my form when the user presses the submit button. If you go to this website you can see the form that the user has to fill out: http://www2.esc.edu/jvooris/assignment5-2.php?formChoice=1 As you can see there are several required fields that the user needs to fill in, however if the user presses submit without filling out the form there is no error message displayed. My code does not seem to be working correctly and the only error I am getting is: Undefined index: UserName So, my question is how do I get this working correctly so that an error message displays if certain fields are not filled in? Any help would be greatly appreciated. I will attach my php files. I know I have only added the UserName error so far in the form-to-email file because I was trying to get one working before adding all the other errors. Thanks. assignment5-2.php form-to-email.php Quote Link to comment Share on other sites More sharing options...
PaulRyan Posted April 12, 2013 Share Posted April 12, 2013 (edited) $name = isset($_GET['UserName']) ? $_GET['UserName'] : NULL ; Ternary Operator Edited April 12, 2013 by PaulRyan Quote Link to comment Share on other sites More sharing options...
Movies32 Posted April 14, 2013 Author Share Posted April 14, 2013 I was finally able to get the errors to show up, but now my problem is that all the errors show up when the user presses submit. For instance, if the user enters all the necessary information into the Help Form then the errors for the Feedback Form will show up even though the user only wants to enter information into the Help Form. The same goes if the user just wants to enter information into the Feedback Form. Does anyone have a suggestion of how I can code this so only the right errors show up at the right time? Also, how could I check to make sure that one of the checkboxes is checked in the Help Form using the same method? assignment5-2.php form-to-email.php Quote Link to comment Share on other sites More sharing options...
Movies32 Posted April 22, 2013 Author Share Posted April 22, 2013 Can anyone help please? I will attach my code. assignment5-2.php form-to-email.php Quote Link to comment 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.