Kaseye Girls - News
"See the Good Things of the Lord"

We are back


Fiction   24 April 2026

We are back

<?php 
session_start();
include('includes/config.php');

error_reporting(E_ALL);
ini_set('display_errors',1);

// Check login
if(empty($_SESSION['login'])){
    header("Location: index.php");
    exit();
}

// Get post id
$postid = isset($_GET['pid']) ? intval($_GET['pid']) : 0;


// UPDATE POST
if(isset($_POST['update'])){

$posttitle = mysqli_real_escape_string($con,$_POST['posttitle']);
$catid = intval($_POST['category']);
$subcatid = "NULL"; // subcategory disabled
$postdetails = mysqli_real_escape_string($con,$_POST['postdescription']);
$lastuptdby = $_SESSION['login'];

$arr = explode(" ",$posttitle);
$url = implode("-",$arr);

$status = 1;

$query = mysqli_query($con,"UPDATE tblposts SET 
PostTitle='$posttitle',
CategoryId='$catid',
SubCategoryId=$subcatid,
PostDetails='$postdetails',
PostUrl='$url',
Is_Active='$status',
lastUpdatedBy='$lastuptdby'
WHERE id='$postid'");

if($query){
$msg="Post updated successfully";
}else{
$error="Something went wrong : ".mysqli_error($con);
}

}
?>
<!DOCTYPE html>
<html lang="en">
<head>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Kaseye Girls-Admin Edit Post</title>
<link rel="shortcut icon" href="img/logo5.png" type="image/png">

<link href="../plugins/summernote/summernote.css" rel="stylesheet" />
<link href="dist/w3css/w3.css" rel="stylesheet">
<link href="../plugins/select2/css/select2.min.css" rel="stylesheet" />
<link href="../plugins/jquery.filer/css/jquery.filer.css" rel="stylesheet" />

<link href="assets/css/bootstrap.min.css" rel="stylesheet" />
<link href="assets/css/core.css" rel="stylesheet" />
<link href="assets/css/components.css" rel="stylesheet" />
<link href="assets/css/icons.css" rel="stylesheet" />
<link href="assets/css/pages.css" rel="stylesheet" />
<link href="assets/css/menu.css" rel="stylesheet" />
<link href="assets/css/responsive.css" rel="stylesheet" />

<script src="assets/js/modernizr.min.js"></script>

</head>

<body class="fixed-left">

<div id="wrapper">

<?php include('includes/topheader.php');?>
<?php include('includes/leftsidebar.php');?>

<div class="content-page">
<div class="content">
<div class="container">

<div class="row text-uppercase">
<div class="col-xs-12">
<div class="page-title-box">
<h4 class="page-title">Edit Post</h4>
<div class="clearfix"></div>
</div>
</div>
</div>


<div class="row">
<div class="col-sm-6">

<?php if(isset($msg)){ ?>
<div class="alert alert-success">
<?php echo htmlentities($msg); ?>
</div>
<?php } ?>

<?php if(isset($error)){ ?>
<div class="alert alert-danger">
<?php echo htmlentities($error); ?>
</div>
<?php } ?>

</div>
</div>


<?php
$query=mysqli_query($con,"SELECT 
tblposts.id as postid,
tblposts.PostImage,
tblposts.PostTitle as title,
tblposts.PostDetails,
tblcategory.CategoryName as category,
tblcategory.id as catid
FROM tblposts
LEFT JOIN tblcategory ON tblcategory.id=tblposts.CategoryId
WHERE tblposts.id='$postid'");
$row=mysqli_fetch_array($query);
?>

<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="p-6">

<form method="post" enctype="multipart/form-data">

<div class="form-group">
<label>POST TITLE</label>
<input type="text" class="form-control" 
name="posttitle"
value="<?php echo htmlentities($row['title']); ?>"
required>
</div>

<div class="form-group">
<label>CATEGORY</label>
<select class="form-control" name="category" required>

<option value="<?php echo $row['catid']; ?>">
<?php echo $row['category']; ?>
</option>

<?php
$ret=mysqli_query($con,"SELECT id,CategoryName FROM tblcategory WHERE Is_Active=1");
while($result=mysqli_fetch_array($ret)){
?>

<option value="<?php echo $result['id']; ?>">
<?php echo $result['CategoryName']; ?>
</option>

<?php } ?>

</select>
</div>

<input type="hidden" name="subcategory" value="NULL">


<label>POST DETAILS</label>
<textarea class="summernote" name="postdescription">
<?php echo htmlentities($row['PostDetails']); ?>
</textarea>

<br>

<label>POST IMAGE</label><br>
<img src="postimages/<?php echo htmlentities($row['PostImage']); ?>" width="300">

<br><br>

<a href="change-image.php?pid=<?php echo $row['postid']; ?>"
class="btn btn-primary">CHANGE IMAGE</a>

<br><br>

<button type="submit" name="update"
class="btn btn-success">
UPDATE POST
</button>

</form>

</div>
</div>
</div>

</div>
</div>

<?php include('includes/footer.php');?>

</div>
</div>

<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>

<script src="../plugins/summernote/summernote.min.js"></script>

<script>
$('.summernote').summernote({
height:240
});
</script>

</body>
</html>

Share: Facebook | Twitter | WhatsApp | LinkedIn    Visits: 49


Leave a Comment:



KASEYE GIRLS SECONDARY SCHOOL

"See the Good things of the Lord"

Open from Monday to Friday from 7:00 am to 4:30 pm