Hello,
I have created many section like update delete etc on the webpage i stored a message in the session variable so when users updates deletes etc on the page a message comes up logo updated sucessfully message posted successfully etc etc so that message is stored in session variaable once things are done and on that page a message is then retrieved so that message will be stored until unless we logged out correct as then session is destroyed so I placed null once the message is viewed once so on next refresh the message is then destroyed but when I placed null the message is not coming up I hope i hade it clear and what help I am looking for
Here is my update query code
function update_banner($connect, $id) {
$bannername = $_FILES["bgimg"]["name"];
$imgtype = $_FILES["bgimg"]["type"];
$imgtemp = $_FILES["bgimg"]["tmp_name"];
$path = "./img/banners/".$bannername;
$heading = $_POST["bheading"];
$sptext = mysqli_real_escape_string($connect, $_POST["sptext"]);
$btnlink = $_POST["btnlink"];
$btntext = $_POST["btntext"];
$section = $_POST["section"];
move_uploaded_file($imgtemp, $path);
if(!empty($bannername)) {
$query_insert = "UPDATE banners SET banner_heading='$heading', spantext='$sptext', button='$btntext', buttonlink='$btnlink', bgimg='$bannername', section='$section' WHERE bid='$id'";
$confirm = mysqli_query($connect, $query_insert);
} else {
$query_insert = "UPDATE banners SET banner_heading='$heading', spantext='$sptext', button='$btntext', buttonlink='$btnlink', section='$section' WHERE bid='$id'";
$confirm = mysqli_query($connect, $query_insert);
}
if($confirm) {
$_SESSION["message"] = "Banner updated successfully";
header("Location: optiontheme.php?id=".$_SESSION["id"]);
} else {
$_SESSION["message"] = "There was some errors please re-enter your information";
header("Location: optiontheme.php?id=".$_SESSION["id"]);
}
}
and here is my session function of message
session_start();
function message() {
if(isset($_SESSION['message'])) {
$output = "<div class='msg'>";
$output .= $_SESSION['message'];
$output .= "</div>";
$_SESSION['message'] = null;
return $output;
}
}
then the message is called like this
echo message();