I use the following code to add a news item to a club website (all works fine). However, I would like to add to the code so I can email all club members about the update (same database different table). I have tried several ways but just can’t get it to work. Any advice appreciated.
<?php
$date=$_POST['date'];
$time=$_POST['time'];
$subject=$_POST['subject'];
$category=$_POST['category'];
$article = addslashes($_POST['content']);
$source=$_POST['source'];
// Create & Check Connection //
include("connect.php");
// Insert News Item //
$sql = "INSERT INTO news (date, time, subject, category, article, source)
VALUES ( '$date', '$time', '$subject', '$category', '$article', '$source')";
// Redirect //
if ($conn->query($sql) === true) {
echo "";
header("Refresh: 2;url=add-news.php");
echo "<div style='text-align:center;margin-top:50px;font:Arial;'>";
echo "<p>New NEWS ITEM created successfully.</p>";
echo "<p>You will be redirected back to the Entry Page in 2 seconds.<br></p>";
echo "<p>If you are not redirected yet, <a href='add-news.php'>click here</a></p></div>.";}
else { echo "Error: " . $sql . "<br>" . $conn->error; };
$conn->close();
?>