D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
diafrica
/
spre.dominicaninstitute.edu.ng
/
Filename :
add-document.php
back
Copy
<?php session_start(); 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['doc_id'])) { $sn = $_GET['doc_id']; $sql = "DELETE FROM document WHERE sn='$sn'"; if (mysqli_query($con, $sql)) { $message = 'Document deleted successfully!'; $_GET['faq_id'] = ''; } else { $message = 'Error deleting picture: ' . mysqli_error($con); } } ?> <div class="container" style="margin-top:50px"> <div> <a href="./mod-auth"><h2>Back to Admin Dashboard</h2></a> </div> <hr> <div> <h1>Add Document</h1> <?php if ( $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['add_programme']) ) { $titler = $category = $image = $dater = $ckeditor = $contenter = ''; $titler = test_input($_POST['titler']); // $dater = test_input($_POST['dater']); //$caption = test_input($_POST['caption']); //$ckeditor = $_POST['ckeditor']; $file_name = $_FILES['document']['name']; $file_path = 'uploads/programme/' . $file_name; move_uploaded_file($_FILES['document']['tmp_name'], $file_path); $feedback = "INSERT INTO document (titler, document) VALUES ('$titler', '$file_name')"; // echo $feedback; // exit(); $run = mysqli_query($con, $feedback); if ($feedback) { echo "<div class='alert alert-success alert-dismissible' role='alert'> Faq Added Successfully! </div>"; $_POST['titler'] = ''; $_POST['caption'] = ''; $_POST['ckeditor'] = ''; $file_name = ''; } else { echo "<div class='alert alert-danger alert-dismissible' role='alert'> An error occured, please try again! </div>"; } } ?> <br> <form action="<?php echo htmlspecialchars( $_SERVER['PHP_SELF'] ); ?>" 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" placeholder="Document Name" required> </div> <!-- <div class="form-group"> <input type="text" name="caption" class="form-control" placeholder="Programme caption" required> </div> --> <div class="form-group"> <p>Select Document To Upload</p> <input type="file" name="document" class="form-control" size="60" required> </div> <!-- <div class="form-group"> <textarea name="ckeditor" class="form-control textarea required" ></textarea> <script> CKEDITOR.replace( 'ckeditor' ); // 850 pixels wide. config.width = '100%'; config.height = '8700px' </script> </div> --> <div class="form-group"> <input type="submit" name="add_programme" value="Add Document" class="thm-btn thm-color width-100"/> </div> </div> </div> </form> </div> <hr> <div> <h1>Existing Document</h1> <?php if (!empty($message)): ?> <div class='alert alert-danger alert-dismissible show' role="alert"> <?= $message ?> </div> <?php endif; ?> <?php include_once './inc/config.php'; $serial = 0; $sql = 'SELECT * FROM document'; $result = mysqli_query($con, $sql); ?> <table id="example" class="display" style="width:100%"> <thead> <tr> <th>S/N</th> <!-- <th>Images</th> --> <th>Title</th> <th>Document</th> <th>Actions</th> <th></th> </tr> </thead> <tbody> <?php if (mysqli_num_rows($result) > 0) { // output data of each row while ($row = mysqli_fetch_assoc($result)) { ?> <tr> <td><?= ++$serial ?></td> <!-- <td><img scr="./uploads/news/"/></td> --> <td><?= $row['titler'] ?></td> <td><?= $row['document'] ?></td> <td colspan="2"> <a href="edit-document?doc_id=<?= $row[ 'sn' ] ?>" class="btn btn-success">Edit</a> </td> <td><a href="add-document?doc_id=<?= $row[ 'sn' ] ?>" class="btn btn-danger">Delete</a> </td> </tr> <?php } } else { //echo '0 results'; } ?> </tbody> </table> </div> </div> </div> <?php include_once 'sections/footer.php'; ?>