D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home2
/
technoi4
/
www
/
admin
/
Filename :
_index.php.working
back
Copy
<?php require_once('header.php'); require_once('config.php'); ?> <head> <title>Techno_Gulf | Categary</title> </head> <body> <?php require('sidebar.php'); ?> <main class="page-content"> <div class="container-fluid"> <h2>Add Category</h2> <hr> <div class="btn btn-group"> <button id="one" class="btn btn-group btn-primary">INSERT</button> <button id="two" class="btn btn-group btn-danger">VIEW</button> </div> <div class="mt-5"></div> <div class="on"> <form method="post" enctype="multipart/form-data"> <div class="row"> <div class="col-md-12"> <div class="form-group"> <label for="exampleInputPassword1">Categary_Name</label> <input type="text" class="form-control" name="categary_title"> </div> <div class="form-group"> <label for="exampleInputPassword1">Categary_Desc</label> <textarea class="form-control" id="editor" name="desc"></textarea> </div> <div class="form-group"> <label for="exampleFormControlFile1">Image</label> <input type="file" class="form-control-file" name="image"> </div> <button type="submit" name="add" class="btn btn-warning">Add</button> </div> </div> </form> </div> <div class="to"> <div id="buttons"></div> <!-- Table --> <table id="product" class="table table-striped table-hover dt-responsive" cellspacing="0" width="100%"> <thead> <tr> <th>Id </th> <th>Categary Name </th> <th>Description </th> <th>Image </th> <th>Edit</th> <th>Delete</th> </tr> </thead> </table> </div> </div> <?php if (isset($_POST['add'])) { $categary_title = $_POST['categary_title']; $desc = addslashes($_POST['desc']); $image = $_FILES['image']['name']; $is_deleted = 0; $dir = 'img/categary/'; if (!empty($image) && isset($image)!=NULL) { $extension = array("jpeg", "jpg", "png", "gif", "JPG"); $ext = pathinfo($_FILES["image"]["name"], PATHINFO_EXTENSION); $pimage = $_FILES['image']['name']; require('config.php'); if (in_array($ext, $extension)) { $query = "INSERT INTO `categary`(`categary_title`, `desc`, `image`, `is_deleted`) VALUES ('$categary_title','$desc','$image','$is_deleted')"; $res = mysqli_query($conn, $query); if ($res) { move_uploaded_file($_FILES['image']['tmp_name'], "$dir" . $image); echo '<script type="text/JavaScript"> window.location="index.php"</script>'; } else echo "eror = " . mysqli_error($conn); } else { echo "Please, Select the file from the following extension: jpeg, jpg, png, gif"; } } else { $query = "INSERT INTO `categary`(`categary_title`, `desc`, `is_deleted`) VALUES ('$categary_title','$desc', '$is_deleted')"; $res = mysqli_query($conn, $query); if ($res) { echo '<script type="text/JavaScript"> window.location="index.php"</script>'; } } } ?> </main> <!-- Script --> <script> $(document).ready(function () { var dataTable = $('#product').DataTable({ 'processing': true, 'serverSide': true, "responsive": true, 'serverMethod': 'post', "lengthMenu": [[10, 25, 50, 100,500,1000], [10, 25, 50,100,500,1000]], 'dom': 'Blfrtip', 'buttons': [ ], 'ajax': { 'url':'ajaxfile.php', }, 'columns': [ { data: 'id' }, { data: 'categary_title' }, { data: 'desc' }, { data: 'image' }, { data: 'edit' }, { data: 'delete' }, ] }); }); $(document).ready(function() { $('#product').DataTable(); $(".on").hide(); console.log("ready!"); $("#one").click(function() { $(".on").show(); $(".to").hide(); }); $("#two").click(function() { $(".to").show(); $(".on").hide(); }); }); </script> <script> $('#selector').change(function(){ if($(this).val() == "no" ){ $('.otherprof').slideUp(); }else{ $('.otherprof').slideDown(); } }); </script> <script> $('#selector_new').change(function(){ if($(this).val() == "no" ){ $('.other_prof').slideUp(); }else{ $('.other_prof').slideDown(); } }); </script> <?php include('footer.php'); ?>