brentaserio Posted December 28, 2008 Share Posted December 28, 2008 Hello Everyone, I'm working on an Internal PHP Form Emailer. This forms primary function is to request support from our IT staff. I managed to get everything work as it is supposed to but there is an annoying little nitch. If I leave the field(s) blank meaning at least 2 fields that are required, it prints the error message once per blank field. Just below is an example, if I leave 3 fields blank. A PROBLEM HAS BEEN ENCOUNTERED The following field(s) have not value: "Requestee Email Address" Please CLICK HERE to complete the form! A PROBLEM HAS BEEN ENCOUNTERED The following field(s) have not value: "Requestee Last Name" Please CLICK HERE to complete the form! A PROBLEM HAS BEEN ENCOUNTERED The following field(s) have not value: "Requestee First Name" Please CLICK HERE to complete the form! I know why this is happening, but cannot fix it as I am not too experienced with PHP. Here is my code. $fields=array('"Requestee Email Address"' => $remail, '"Requestee Last Name"' => $rlname, '"Requestee First Name"' => $rfname); foreach($fields as $key => $val) { if(empty($val)) { $error_msg ="$key<br \>"; Print "<h3>A PROBLEM HAS BEEN ENCOUNTERED</h3><p>The following field(s) have not value:</p>$error_msg <p>Please<a href='javascript:history.back()'><u> CLICK HERE</u></a> to complete the form!</p>"; } } if($error_msg=='') { echo "Good Job!"; } Any help would be greatly appreciated. Thanks~ Link to comment https://forums.phpfreaks.com/topic/138674-functional-emailer-w-nitch/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.