D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
diafrica
/
spre.dominicaninstitute.edu.ng
/
Filename :
edit-newsevent.php
back
Copy
<?php session_start(); include 'inc/config.php'; include './inc/functions.php'; $Functions = new Functions(); if (!isset($_SESSION['manager'])) { header('location: ./admin-auth'); exit(); } $page_title; $page_title = ucfirst(basename(__FILE__, '.php')); if ($page_title === 'index') { $page_title = 'Home'; } $page_title = "Administator's Dashboard"; include 'sections/pages-header.php'; $message = ''; function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } if (isset($_GET['news_id'])) { $sn = $_GET['news_id']; $get_news = "select * from news where sn='$_GET[news_id]'"; $run_post = mysqli_query($con, $get_news); while ($row_post = mysqli_fetch_array($run_post)) { $titler = $row_post['titler']; $category = $row_post['category']; $dater = $row_post['dater']; $uploaded_image = $row_post['image']; $contenter = $row_post['contenter']; } } ?> <div class="container" style="margin-top:50px"> <div> <a href="./newsevent"><h2> Manage News</h2></a> </div> <hr> <div> <h1>Update News</h1> <?php if ( $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update_news']) ) { $titler = $category = $image = $dater = $ckeditor = ''; $titler = test_input($_POST['titler']); $dater = test_input($_POST['dater']); $category = test_input($_POST['category']); $ckeditor = $_POST['ckeditor']; $file_name = $_FILES['image']['name'] ? $_FILES['image']['name'] : $uploaded_image; $file_path ='uploads/news/' . $file_name; move_uploaded_file($_FILES['image']['tmp_name'], $file_path); $feedback = "UPDATE news SET titler='$titler', contenter='$ckeditor',category='$category', dater='$dater', image ='$file_name' WHERE sn =$sn"; // echo $feedback; // exit(); $run = mysqli_query($con, $feedback); if ($feedback) { echo "<div class='alert alert-success alert-dismissible' role='alert'> News Updated Successfully! </div>"; } else { echo "<div class='alert alert-danger alert-dismissible' role='alert'> An error occured, please try again! </div>"; } } ?> <?php $get_news = "select * from news where sn='$_GET[news_id]'"; $run_post = mysqli_query($con, $get_news); while ($row_post = mysqli_fetch_array($run_post)) { $titler = $row_post['titler']; $category = $row_post['category']; $dater = $row_post['dater']; $uploaded_image = $row_post['image']; $contenter = $row_post['contenter']; } ?> <br> <form action="" method="post" enctype="multipart/form-data"> <div class="row clearfix"> <div class="col-md-8 col-sm-12 col-xs-12"> <div class="form-group"> <input type="text" name="titler" class="form-control" value="<?= $titler ?>" placeholder="Add news title" required> </div> <div class="form-group"> <input type="text" name="category" class="form-control" placeholder="Add new Category" value="<?= $category ?>"required> </div> <div class="form-group"> <img src="uploads/news/<?= $uploaded_image ?>" style="width: 300px"/> <p>Change News image News Dimension 560 x 581</p> <input type="file" name="image" class="form-control" size="60"> </div> <div class="form-group"> <input type="date" name="dater" class="form-control" value="<?= $dater ?>" required> </div> <div class="form-group"> <textarea name="ckeditor" class="form-control textarea required" ><?= $contenter ?></textarea> <script> CKEDITOR.replace( 'ckeditor' ); // 850 pixels wide. config.width = '100%'; config.height = '8700px' </script> </div> <div class="form-group"> <input type="submit" name="update_news" value="Update News" class="thm-btn thm-color width-100"/> </div> </div> </div> </form> </div> <hr> </div> </div> <?php include_once 'sections/footer.php'; ?>