I used isset()
function so that I will not receive the blank email. I can still receive blank emails.
Please see my code
Is !empty()
better than isset()
?
What is the difference between the two?
Many Thanks
if (isset($_POST['name']) && isset($_POST['email']) && isset($_POST['phone'])){
$postcode = isset($_POST['postcode']) ? $_POST['postcode'] : "";
$name = isset($_POST['name']) ? $_POST['name'] : "";
$email = isset($_POST['email']) ? $_POST['email'] : "";
$phone = isset($_POST['phone']) ? $_POST['phone'] : "";
$business = isset($_POST['business']) ? $_POST['business'] : "";
$to = 'rme@btel.com';
$subject = "=?UTF-8?B?" . base64_encode('Message from BTelecom') . "?=";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=utf-8\r\n";
@$message = '<!DOCTYPE html><html><body>' .
'Post Code: ' . strip_tags($postcode) . '<br/>' .
'Email: ' . strip_tags($email) . '<br/>' .
'Name: ' . strip_tags($name) . '<br/>' .
'Phone: ' . strip_tags($phone) . '<br/>' .
'Business: ' . strip_tags($business) . '' .
'</body></html>';
$actual_link = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$result = mail($to, $subject, $message, $headers);
}