I am completely unable to get this to work.
I am following a course on Udemy.com, "The Complete PHP MYSQL Professional Course with 5 Projects". On video #115 "Approve Comments", I have the exact same code as he does.
His code sets the un-approved comment to approved and then adds the comment to the comment section. My code shows a message saying that it was successful, but in reality, nothing happened and the comment is still un-approved.
Here is my code:
<?php require_once("Includes/Functions.php"); ?>
<?php require_once("Includes/Sessions.php"); ?>
<?php
if(isset($_GET["id"])) {
$SearchQueryParameter = $_GET["id"];
global $ConnectingDB;
$Admin = $_SESSION["AdminName"];
$sql = "UPDATE comments SET status='ON', approvedby='$Admin' WHERE id='$SearchQueryParameter'";
$Execute = $ConnectingDB->query($sql);
if ($Execute) {
$_SESSION["SuccessMessage"]="Comment Approved Successfully! The comment is now visible to anyone.";
Redirect_to("Comments.php");
} else {
$_SESSION["ErrorMessage"]="Something went wrong. Try Again.";
Redirect_to("Comments.php");
}
}
?>
<?php // FIXME: ERROR WITH CHANGING COMMENTS TO APPROVED! ?>