Hello PHP Help community! I’m stuck modifying some php code to make it fit my needs. The code I haven’t included works great but I believe the culprit to be located in the following code.
If the required form field(s) are not filled in, and the user hits the “Send message” button, then the user is prompted with a message stating “Your message was not sent… Please complete all fields.” This part works as intended.
But when all of the required fields are filled in, and the user hits the “Send message” button, they are not presented with the proper message, “Your message has been sent.”. But I still receive all of the information entered into the form fields.
I believe my error is in the placement/logic of
php[/php] and its corresponding echo message.
[php]
// this does great checking for missing fields and printing the proper statement if a field(s) are missing
// but when all fields are present the proper message is NOT printed (your message has been sent) but it does actually send the information
if( (empty($name)) || (empty($subject)) || (empty($email)) || (empty($message)) ) {
echo ’
Please complete all fields.
‘.$phpmailer->ErrorInfo.’
} elseif(!$phpmailer->Send()) {
echo ’
Thank You!
}
[/php]