送信ボタンをクリックすると、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");
}
}
}