D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home2
/
technoi4
/
www
/
admin
/
Filename :
product.php
back
Copy
<?php require_once('header.php'); require_once('config.php'); ?> <head> <title>Techno_Gulf | Product</title> </head> <body> <?php require('sidebar.php'); ?> <main class="page-content"> <div class="container-fluid"> <h2>Add Product</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> <select class="form-control" name="cid"> <option value="">Select Categary_Name</option> <?php require('config.php'); $result = mysqli_query($conn,"SELECT * FROM categary"); while($row = mysqli_fetch_array($result)) { ?> <option value="<?php echo $row['id'];?>"><?php echo $row["categary_title"];?></option> <?php } ?> </select> </div> <div class="form-group"> <label for="exampleInputPassword1">Brand_Name</label> <select class="form-control" name="bid"> <option value="">Select Brand_Name</option> <?php require('config.php'); $result = mysqli_query($conn,"SELECT * FROM brand"); while($row = mysqli_fetch_array($result)) { ?> <option value="<?php echo $row['id'];?>"><?php echo $row["brand_name"];?></option> <?php } ?> </select> </div> <div class="form-group"> <label for="exampleInputPassword1">Product_Name</label> <input type="text" class="form-control" name="product_name"> </div> <div class="form-group"> <label for="exampleInputPassword1">Product_Desc</label> <textarea class="form-control" id="editor" name="product_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>Brand Name </th> <th>Product Name </th> <th>Product Description </th> <th>Image </th> <th>Edit</th> <th>Delete</th> </tr> </thead> </table> </div> </div> <?php if (isset($_POST['add'])) { $cid = $_POST['cid']; $bid = $_POST['bid']; $product_name = $_POST['product_name']; $product_desc = addslashes($_POST['product_desc']); $image = $_FILES['image']['name']; $is_deleted = 0; $dir = 'img/product/'; if (!empty($image) && isset($image)!=NULL) { $extension = array("jpeg", "jpg", "png", "gif", "JPG"); $ext = pathinfo($_FILES["image"]["name"], PATHINFO_EXTENSION); $image = $_FILES['image']['name']; require('config.php'); if (in_array($ext, $extension)) { $query = "INSERT INTO `product`( `cid`, `bid`, `product_name`, `product_desc`, `image`, `is_deleted`) VALUES ('$cid', '$bid', '$product_name', '$product_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="product.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 `product`( `cid`, `bid`, `product_name`, `product_desc`, `is_deleted`) VALUES ('$cid', '$bid', '$product_name', '$product_desc', '$is_deleted')"; $res = mysqli_query($conn, $query); if ($res) { echo '<script type="text/JavaScript"> window.location="product.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':'productajax.php', }, 'columns': [ { data: 'pid' }, { data: 'categary_title' }, { data: 'brand_name' }, { data: 'product_name' }, { data: 'product_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'); ?>