我希望我的提交按钮在单击时运行 if else 语句。在我的用户表中的“完成”字段中,如果值为 6 或更高,则应发送电子邮件(我有此代码),否则应显示错误或重定向到错误页面(我可以创建)。这是我的尝试,但即使值为 6 也会显示错误消息
$usr_email = 'usr_email';
$user_name = 'user_name';
{
$sqltest = "SELECT complete From users where user_id =
".intval($_SESSION['user_id']);
}
if (isset($_POST['doSend'])) {
function getOne($query){
$res = mysql_query($query);
if (!$res) {
trigger_error("db: ".mysql_error()." in ".$query);
return FALSE;
}
}
if ($row = mysql_fetch_row($res)) {
return $row[0];
}
$isSending = getOne($sqltest);
$isSending === false;
if($isSending >= 6){
require_once "Mail.php";
$from = "<xxx>";
$to = "$usr_email";
$subject = "Hi";
$body = hello ";
$host = "ssl://smtp.gmail.com";
$port = "465";
$username = "xxx";
$password = "xxx";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
header ("Location: error.php");
}
}
}