D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
diafrica
/
public_html
/
Filename :
add_news.php
back
Copy
<?php include 'includes/config.php'; session_start(); if (isset($_POST['username']) && isset($_POST['password'])) { $manager = $_POST['username']; $password = $_POST['password']; $cmem = "SELECT id FROM auth WHERE username='$manager' AND password='$password' LIMIT 1"; $run_cmem = mysqli_query($con, $cmem); $count_mem = mysqli_num_rows($run_cmem); if ($count_mem == 1) { while ($row = mysqli_fetch_array($run_cmem)) { $id = $row['id']; } $_SESSION['id'] = $id; $_SESSION['manager'] = $manager; $_SESSION['password'] = $password; header('location: mod-auth'); exit(); } else { echo "<script>alert('Incorrect Password !!!')</script>"; echo "<script>window.open('sacredheartdadmin','_self')</script>"; exit(); } } ?> <?php $page_title; $page_title = ucfirst(basename(__FILE__, '.php')); if ($page_title === 'index') { $page_title = 'Home'; } $page_title = "Add News page"; include 'section/header.php'; include 'section/pages-header.php'; include 'includes/functions.php'; $Functions = new Functions(); ?> <!DOCTYPE html> <html dir="ltr" lang="en"> <!-- Start main-content --> <div class="main-content"> <!-- Section: Team --> <section id="team"> <div class="container"> <div class="row mtli-row-clearfix mb-5000"> <?php if (isset($_GET['sn'])) { $sn = $_GET['sn']; $delete = "delete from events where id='$sn'"; $run = mysqli_query($con, $delete); if ($delete) { echo "<div class='alert alert-danger'> Carousel deleted successfully! </div>"; echo "<script>window.open('add_news','_self')</script></script>"; } } ?> <div class="col-lg-9"> <p><a href="mod-auth">Go back to Admin Dashboard</a></p> <?php if (isset($_POST['addnews'])) { $title = str_replace("'", "''", $_POST['title']); $date = str_replace("'", "''", $_POST['date']); $content = str_replace("'", "''", $_POST['content']); $filename = $_FILES['file']['name']; $type = 'news'; $filepath = 'images/blog/' . $filename; move_uploaded_file($_FILES['file']['tmp_name'], $filepath); global $con; if ($filename == ""){ $query = "INSERT INTO events (title, date, content) VALUES ('$title','$content')"; $query_run = mysqli_query($con, $query); }else{ $query = "INSERT INTO events (title, date, content,image) VALUES ('$title','$content','$filepath')"; $query_run = mysqli_query($con, $query); } if ($query_run) { echo "<div class='alert alert-success'> Added Successfully! </div>"; } else { echo "<div class='alert alert-danger'> An error occured, please try again! </div>"; } } ?> <h3 style="color: #17569E;">Add News!</h3> <?php // $query = "SELECT * FROM content WHERE id='1' "; // $query_run = mysqli_query($con, $query); // while ($row_post = mysqli_fetch_array($query_run)) { // $title = $row_post['title']; // $link = $row_post['link']; // $contenter = $row_post['content']; // } ?> <form id="form1" name="form1" method="post" action="" enctype="multipart/form-data"> <table width="100%" cellpadding="1" cellspacing="2"> <div class="mb-3"> <label>Title</label> <input type="text" name="title" class="form-control" required> </div> <div class="mb-3"> <label>Date</label> <input type="text" name="date" class="form-control" required> </div> <div class="mb-3"> <label>Image Dimension: 450 x 500</label> <input name="file" type="file" accept=".png,.jpeg,.jpg,.svg,.gif,.tiff" class="form-control"> </div> <div class="mb-3"> <label>Content</label> <textarea id="editor" type="text" name="content" class="form-control"></textarea> <script> ClassicEditor .create( document.querySelector( '#editor' ) ) .then( editor => { console.log( editor ); } ) .catch( error => { console.error( error ); } ); </script> </div> <div class="mb-3"> <input style="margin-left: 100px;" name="addnews" type="submit" style="font-size:12px;" class="btn btn-dark" id="addnews" value="Add News" /> </div> </table> </form> <hr/> <p style="color:#990000"><b>Existing News</b></p> <?php $get_feedback = "select * from events where type = 'news' order by id desc"; $run_feedback = mysqli_query($con, $get_feedback); while ($row_feedback = mysqli_fetch_array($run_feedback)) { $sn = $row_feedback['id']; $image = $row_feedback['image']; $title = $row_feedback['title']; echo " <div class='row' style='margin-bottom: 10px;border-bottom: 1px solid #E6E6E6;padding: 10px;padding-left: 0px;'> <div class='col-lg-3'> <img src='$image' height='70' width='70'/> </div> <div class='col-lg-5'> $title </div> <div class='col-lg-1'> </div> <div class='col-lg-3'> <a href='add_news?sn=$sn' style='color: red;'>Delete</a> </div> </div> "; } ?> </div> </div> </div> </section> </div> <!-- end main-content --> <?php include_once 'section/footer.php'; ?>