D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
diafrica
/
public_html
/
Filename :
add_faq.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 FAQ 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 faq 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_faq','_self')</script></script>"; } } ?> <div class="col-lg-9"> <p><a href="mod-auth">Go back to Admin Dashboard</a></p> <?php if (isset($_POST['addfaq'])) { $question = str_replace("'", "''", $_POST['question']); $answer = str_replace("'", "''", $_POST['answer']); global $con; $query = "INSERT INTO faq (questions, answer) VALUES ('$question','$answer')"; $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 FAQ!</h3> <form id="form1" name="form1" method="post" action="" enctype="multipart/form-data"> <table width="100%" cellpadding="1" cellspacing="2"> <div class="mb-3"> <label>Question</label> <input type="text" name="question" class="form-control" required> </div> <div class="mb-3"> <label>Answer</label> <textarea id="editor" type="text" name="answer" 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="addfaq" type="submit" style="font-size:12px;" class="default-btn" id="addnews" value="Add FAQ" /> </div> </table> </form> <hr/> <p style="color:#990000"><b>Existing FAQ</b></p> <?php $get_feedback = "select * from faq order by id desc"; $run_feedback = mysqli_query($con, $get_feedback); while ($row_feedback = mysqli_fetch_array($run_feedback)) { $sn = $row_feedback['id']; $question = $row_feedback['questions']; echo " <div class='row' style='margin-bottom: 10px;border-bottom: 1px solid #E6E6E6;padding: 10px;padding-left: 0px;'> <div class='col-lg-5'> $question </div> <div class='col-lg-1'> <a href='update_staff?sn=$sn' style='color: blue;'>Edit</a> </div> <div class='col-lg-3'> <a href='add_faq?sn=$sn' style='color: red;'>Delete</a> </div> </div> "; } ?> </div> </div> </div> </section> </div> <!-- end main-content --> <?php include_once 'section/footer.php'; ?>s