dongzhuji1042 2018-05-17 06:19
浏览 28
已采纳

PHP:收到空白电子邮件

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
";
$headers .= "Content-type: text/html; charset=utf-8
";
@$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);

}
  • 写回答

1条回答 默认 最新

  • doukun8944 2018-05-17 06:38
    关注

    PHP empty function just checks the blank value while on other side isset checks for variable existence.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错
  • ¥20 @microsoft/fetch-event-source 流式响应问题
  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?