Well, you can use function empty()
if (empty($_POST['email']) || empty($_POST['msg'])) {
exit();
}
The better way is to have a proper email validation and message validation. For example:
- Message must be longer than certain length (for example: must be greater than 10 characters)
- Must provide a valid format email (for example: the simplest way and less accurate way to check is to check if
@
exists.