THEoriginalDAG22 Posted June 11, 2007 Share Posted June 11, 2007 Hello everyone, I am new at PHP and am trying to create a feedback form. I created it and it works fine but I have one problem, I want the people who fill it out to be able to see what they forgot to fill out. For example lets say im asking for name, phone number, email address, and message. (in my real form im asking for a lot more but i didnt feel like typing the entire thing) And lets say they forget to put their phone number and message, I want them to see an error message that lets them know they forgot to put their phone number and message. I've seen this done before so I know its possible, can anyone let me know how? thanks for reading, bye. Quote Link to comment https://forums.phpfreaks.com/topic/55151-solved-list-of-errors-in-error-message/ Share on other sites More sharing options...
pocobueno1388 Posted June 11, 2007 Share Posted June 11, 2007 You could do something like this after the form is submitted: <?php //put all your POST data into short variables first, like the ones below...I left this part out for you =] if (empty($name)) $errors[] = "You forgot to put your name!"; if (empty($phone)) $errors[] = "You forgot to put your phone number!"; if (empty($email)) $errors[] = "You forgot an email address!"; if (empty($message)) $errors[] = "You forgot a message!"; if (!empty($errors)){ echo "You had the following errors:<br>"; foreach ($errors as $key => $val){ echo '-'.$val.'<br>'; } } else { echo "You filled out the form successfully."; } ?> Not Tested. Quote Link to comment https://forums.phpfreaks.com/topic/55151-solved-list-of-errors-in-error-message/#findComment-272638 Share on other sites More sharing options...
THEoriginalDAG22 Posted June 11, 2007 Author Share Posted June 11, 2007 THANK YOU FOR RESPONDING SO FAST! I WILL TRY IT AND LET YOU KNOW IF IT WORKED, ONCE AGAIN, THANKS FOR THE HELP! Quote Link to comment https://forums.phpfreaks.com/topic/55151-solved-list-of-errors-in-error-message/#findComment-272639 Share on other sites More sharing options...
THEoriginalDAG22 Posted June 11, 2007 Author Share Posted June 11, 2007 IT WORKED! THANKS AGAIN! Quote Link to comment https://forums.phpfreaks.com/topic/55151-solved-list-of-errors-in-error-message/#findComment-272649 Share on other sites More sharing options...
pocobueno1388 Posted June 11, 2007 Share Posted June 11, 2007 Awesome =D Your welcome. Quote Link to comment https://forums.phpfreaks.com/topic/55151-solved-list-of-errors-in-error-message/#findComment-272653 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.