Viewing file: change_status.php (3.76 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php include("include/conn.php"); require "phpmailer/PHPMailerAutoload.php"; if (isset($_GET['art_id'])) { $art_id = $_GET['art_id']; $status = $_GET['status'];
// Check if the profile exists $checkSql = "SELECT * FROM `articles` WHERE art_id = $art_id"; $checkResult = mysqli_query($conn, $checkSql); $profileExists = mysqli_num_rows($checkResult) > 0;
if ($profileExists) { // Display confirmation message echo "<script> if (confirm('Are you sure you want to Change the status of this Article?')) { window.location.href = 'change_status.php?change=$art_id&&status=$status'; } else { window.location.href = 'articles.php'; } </script>"; } else { echo "Article not found."; } } elseif (isset($_GET['change'])) { $art_id = $_GET['change']; $status = $_GET['status'];
$sql = "UPDATE `articles` SET `art_status`=$status WHERE art_id = $art_id"; $result = mysqli_query($conn, $sql);
if ($result) {
echo "<script>alert('Articles Status Change successfully!');</script>"; echo "<script>window.location.href ='articles.php';</script>";
if ($status == 1) { // Get article details $articleResult = mysqli_query($conn, "SELECT * FROM articles WHERE art_id = $art_id"); $article = mysqli_fetch_assoc($articleResult); $title = $article['art_title']; $art_image = $article['art_image']; // or summary $link = "http://jothidam.tv/article-single.php?id=$art_id"; // Fetch all users $userResult = mysqli_query($conn, "SELECT email FROM users"); while ($user = mysqli_fetch_assoc($userResult)) { $to = $user['email']; $mail = new PHPMailer; $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->Port = 587; $mail->SMTPAuth = true; $mail->SMTPSecure = 'tls'; $mail->Username = 'alpastrology.org@gmail.com'; $mail->Password = 'zolohsvsxtzvrsoy'; $mail->setFrom('alpastrology.org@gmail.com', 'ALP Astrology'); $mail->addAddress($to); $mail->isHTML(true); $mail->Subject = "New Article Published"; // HTML Email Body Design $mail->Body = " <div style='font-family: Arial, sans-serif; padding: 20px; background-color: #f4f4f4;'> <div style='max-width: 600px; margin: auto; background: white; padding: 20px; border-radius: 8px;'> <h2 style='color: #333;'>✨ New Article Published</h2> <h3 style='color: #006699;'>$title</h3> <img src='https://jothidam.tv/admin/$art_image' alt='$title' style='width:300px; border-radius:8px; margin-bottom:15px;'> <p><a href='$link' style='display: inline-block; background-color: #28a745; color: white; padding: 10px 20px; text-decoration: none; border-radius: 4px;'>Read Full Article</a></p> <hr style='margin-top: 30px;'> <small style='color: #999;'>You are receiving this email because you are subscribed to ALP Astrology.</small> </div> </div> "; // Try sending the email and skip if error if (!$mail->send()) { error_log("Failed to send to: $to. Error: " . $mail->ErrorInfo); continue; // Skip and move to next } } } } else { echo "Delete error: " . mysqli_error($conn); } }
|