我只是在向某些用户发送链接访问权限的情况下设置phpmailer服务。该服务运行完美。当我设置一个IF语句并且它没有验证时,我的问题就出来了。我只希望它可以输入if验证。进行验证的时间是$ result =='s'为true,发送邮件,否则($ result =='n'),什么也不做。
我对此错误进行了很多研究,显然没有找到解决方法。 这是针对在ionic 3中内置的移动应用程序,在Apache服务器中具有打字稿和php服务。另外,我还使用了MySQL数据库。
{
<?php
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
header('Content-type: application/json');
header("Access-Control-Allow-Origin: *");
header('Access-Control-Allow-Headers: X-Requested-With, content-type, access-control-allow-origin, access-control-allow-methods, access-control-allow-headers');
include('conecction.php');
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'phpMailer/src/Exception.php';
require 'phpMailer/src/PHPMailer.php';
require 'phpMailer/src/SMTP.php';
$id =$request->id;
$counting = count($request->people);
for($i=0;$i<$counting ;$i++){
$name=$request->people[$i]->name;
$email=$request->people[$i]->mail;
$hash=md5($id.$email);
$sql="select assisted from assistance where mail= '$email' and idmeeting = '$id'";
$result = $conn->query($sql);
if($result == 's'){
$mail = new PHPMailer;
$mail->SMTPDebug = 4;
$mail->setFrom('noresponder@Prueba.com', 'Prueba MeetCoomeva');
$mail->addAddress($email, $name);
$mail->Subject = 'Subject';
$mail->Body = "Message Body "
}
if ($mail->send()) {
$response['message']="Sent.";
} else {
echo "Sending error: " . $mail->ErrorInfo;
}
}
echo json_encode($response);
?>
}
我希望该服务在完成验证$ result ==的操作后组成并发送邮件
仅此,我就收到了500台服务器内部错误。我只希望它在thr验证为true时发送邮件,或者在其他情况下输入时不执行任何操作。
答案 0 :(得分:0)
这还不够:
$sql="select assisted from assistance where mail= '$email' and idmeeting = '$id'";
$result = $conn->query($sql);
if($result == 's'){
$result
包含mysqli_result的实例,而不是简单的字符串,因此将其与s
进行比较将永远不会匹配。您需要首先从结果集中fetch the row,如下所示:
$sql="select assisted from assistance where mail= '$email' and idmeeting = '$id'";
$result = $conn->query($sql);
$row = $result->fetch_row();
if($row[0] == 's'){