所以我有一个系统,你可以在其中添加成员到你的组,电子邮件似乎发送完全没有所有信息,但我收到一个错误,说明$ body是一个未定义的变量,任何建议?
<?php //check member Email matches
$addmember = $link->query("SELECT Email FROM logins WHERE Email ='$memberemail'")->fetch_assoc()['Email'];
$to = $addmember;
$subject = "Becoming part of $leaguename";
$body.="So you want to become part of $leaguename?".PHP_EOL;
$body.="Please click the link below to join!".PHP_EOL;
$body.="http://www.wesbitelink.dev/verify.php?memberemail=$memberemail;".PHP_EOL;
$headers = "From: localhost";
mail($to, $subject, $body, $headers);
header("location: addanothermember.php");
?>
我收到的错误消息是:
Notice: Undefined variable: body
答案 0 :(得分:1)
首先在你可以在这个变量上附加东西之后创建$ body变量
<?php //check member Email matches
$addmember = $link->query("SELECT Email FROM logins WHERE Email ='$memberemail'")->fetch_assoc()['Email'];
$to = $addmember;
$subject = "Becoming part of $leaguename";
$body="So you want to become part of $leaguename?".PHP_EOL;
$body.="Please click the link below to join!".PHP_EOL;
$body.="http://www.wesbitelink.dev/verify.php?memberemail=$memberemail;".PHP_EOL;
$headers = "From: localhost";
mail($to, $subject, $body, $headers);
header("location: addanothermember.php");
?>
试试这个
答案 1 :(得分:1)
这是因为您在.=
之前$body
上使用$body
已定义。将第一个.=
更改为仅=
或之前定义$body
。