D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
shubmkcj
/
designpitara.com
/
dash
/
Filename :
add-blog.php
back
Copy
<?php session_start(); include 'config.php'; if($_SESSION['design1'] == ''){ echo "<script>location.replace('index.php')</script>"; } ?> <!DOCTYPE html> <html lang="zxx"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="description" content=""> <meta name="robots" content="nofollow,noindex"> <meta name="author" content=""> <link rel="icon" href="assets/img/basic/favicon.ico" type="image/x-icon"> <title>DesignPitara | Admin Panel</title> <!-- CSS --> <link rel="stylesheet" href="assets/css/app.css"> <script src='tinymce/tinymce.min.js' type='text/javascript'></script> <script src="jquery.js"></script> </head> <body> <div id="app"> <?php include 'left-menu.php'; ?> <!--Sidebar End--> <?php include 'top.php'; ?> <!-- Right Sidebar --> <div class="page has-sidebar-left height-full"> <div class="container-fluid relative animatedParent animateOnce"> <div class="tab-content pb-3" id="v-pills-tabContent"> <div class="card mb-3 shadow no-b r-0 mt-3"> <div class="row"> <div class="col-md-6"> <div class="white p-3"> <h6>Add Blog</h6> </div> </div> <div class="col-md-6 text-right p-3"> <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Add Category +</button> </div> </div> <div class="card-body"> <form action="" method="post" enctype="multipart/form-data"> <div class="form-row mb-3"> <div class="col-md-12 mb-3"> <label for="validationCustom01">Upload Image</label> <input type="file" class="form-control" name="blog_img" required> </div> </div> <div class="form-row mb-3"> <label>Image Alt</label> <input type="text" class="form-control" name="alt" placeholder="enter image alt" required> </div> <div class="from-row mb-3"> <label>Blog Heading</label> <input type="text" class="form-control" name="heading" placeholder="enter blog heading" required> </div> <div class="form-row mb-3"> <div class="col-md-12"> <div class="form-group"> <label>Blog Description</label> <textarea id='editor' name="blog_content" style='height: 200px;'></textarea> </div> </div> </div> <div class="form-row mb-3"> <div class="col-md-6"> <label>Blog Url</label> <input class="form-control" name="url" placeholder="enter your url"> </div> <div class="col-md-6"> <label>Blog Title</label> <input class="form-control" name="title" placeholder="enter your blog title"> </div> </div> <div class="form-row mb-3"> <div class="col-md-6"> <label>Blog Description</label> <input class="form-control" name="description" placeholder="enter your blog description"> </div> <div class="col-md-6"> <label>Blog keyword</label> <input class="form-control" name="keyword" placeholder="enter your blog keyword"> </div> </div> <div class="form-row mb-3"> <div class="col-md-12 form-group"> <label>Category</label> <select class="form-control" name="category" required> <option>--Select--</option> <?php $cat = "select * from category"; $catresult = mysqli_query($conn,$cat); while($catrow = mysqli_fetch_assoc($catresult)){ ?> <option><?php echo $catrow['category'] ?></option> <?php } ?> </select> </div> </div> <div class="field_wrapper"> <label>Tags</label> <div class="form-row p-2"> <div class="col-md-10 col-lg-10 p-0"> <input type="text" name="field_name[]" class="form-control" value="" placeholder="enter tags"/> </div> <div class="col-md-2 col-lg-2"> <a href="javascript:void(0);" class="add_button btn btn-primary" title="Add field">Add +</a> </div> </div> </div> <button class="btn btn-primary" name="import" type="submit">Submit form</button> </form> </div> </div> </div> </div> </div> </div> <!--/#app --> <!-- Modal --> <div class="modal fade" id="myModal" role="dialog"> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content"> <form action="" method="post"> <div class="modal-header"> <h4 class="modal-title">Add Blog Category</h4> </div> <div class="modal-body"> <div class="form-group"> <label>Category (Use it - on the space)</label> <input class="form-control" name="category" placeholder="enter category"> </div> <div class="form-group"> <label>Title</label> <input class="form-control" name="title" placeholder="enter title"> </div> <div class="form-group"> <label>Description</label> <input class="form-control" name="description" placeholder="enter description"> </div> <div class="form-group"> <label>Keyword</label> <input class="form-control" name="keyword" placeholder="enter keyword"> </div> </div> <div class="modal-footer"> <button type="submit" class="btn btn-primary" name="cat">Submit</button> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </form> </div> </div> </div> <?php if(isset($_POST['cat'])){ $category = $_POST['category']; $title = $_POST['title']; $description = $_POST['description']; $keyword = $_POST['keyword']; $catsql = "select * from category where category='$category'"; $result = mysqli_query($conn,$catsql); $count = mysqli_num_rows($result); if($count == 0){ $sql = "INSERT INTO `category`(`category`, `title`, `desciption`, `keyword`) VALUES ('$category','$title','$description','$keyword')"; if(mysqli_query($conn,$sql) == true){ echo "<script>alert('Category Added Successfully')</script>"; echo "<script>location.replace('view-catgory.php')</script>"; }else{ echo "<script>alert('Error ! ')</script>"; } }else{ echo "<script>alert('Error ! Category Already Added')</script>"; } } ?> <script src="assets/js/app.js"></script> <script> tinymce.init({ selector: '#editor', height: 500, menubar: false, plugins: [ 'advlist autolink lists link image charmap print preview anchor textcolor', 'searchreplace visualblocks code fullscreen', 'insertdatetime media table contextmenu paste code help wordcount' ], mobile: { theme: 'mobile' }, toolbar: 'insert | undo redo | formatselect | bold italic backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | help | link image', content_css: [ '//fonts.googleapis.com/css?family=Lato:300,300i,400,400i', '//www.tiny.cloud/css/codepen.min.css' ], }); // $(document).ready(function(){ // // Add TinyMCE // addTinyMCE(); // // Toggle Editor // $('#but_toggle').click(function(){ // // Check TinyMCE initialized or not // if(tinyMCE.get('editor')){ // // Remove instance by id // tinymce.remove('#editor'); // }else{ // // Add TinyMCE // addTinyMCE(); // } // }); // }); // // Add TinyMCE // function addTinyMCE(){ // // Initialize // tinymce.init({ // selector: '#editor', // themes: 'modern', // height: 200 // }); // } </script> <script type="text/javascript"> $(document).ready(function(){ var maxField = 10; //Input fields increment limitation var addButton = $('.add_button'); //Add button selector var wrapper = $('.field_wrapper'); //Input field wrapper var fieldHTML = '<div class="field_wrapper col-md-8 p-0"><input type="text" class=" form-control" name="field_name[]" value=""/><a href="javascript:void(0);" class="remove_button btn btn-danger">Remove -</a></div>'; //New input field html var x = 1; //Initial field counter is 1 //Once add button is clicked $(addButton).click(function(){ //Check maximum number of input fields if(x < maxField){ x++; //Increment field counter $(wrapper).append(fieldHTML); //Add field html } }); //Once remove button is clicked $(wrapper).on('click', '.remove_button', function(e){ e.preventDefault(); $(this).parent('div').remove(); //Remove field html x--; //Decrement field counter }); }); </script> </body> </html> <?php if(isset($_POST['import'])){ if(isset($_FILES["blog_img"]) && $_FILES['blog_img']['size'] != 0){ /* Rename Image */ $time_now=mktime(date('h')+5,date('i')+30,date('s')); $serialNo = date('dmYHis', $time_now); $targetDirectory = "../image/"; /* Explode Extension*/ $temp = explode(".", $_FILES["blog_img"]["name"]); $extension = end($temp); $copyPath = $targetDirectory."design_agency_portfolio_".$serialNo.".".$extension; if(file_exists($copyPath)){ unlink($copyPath); } /* New Name Given Here */ $signatureImageName = "design_agency_portfolio_".$serialNo.".".$extension; move_uploaded_file($_FILES["blog_img"]["tmp_name"], $copyPath); } $alt = $_POST['alt']; $heading = $_POST['heading']; $or_heading = str_replace("'", "\'", $heading); /* Blog Content */ $blog_content = $_POST['blog_content']; $blog_content_area = str_replace("'", "\'", $blog_content); $blog_url = $_POST['url']; $blog_url_area = str_replace("'", "\'", $blog_url); $blog_title = $_POST['title']; $blog_title_area = str_replace("'", "\'", $blog_title); $blog_description = $_POST['description']; $blog_description_area = str_replace("'", "\'", $blog_description); $blog_keyword = $_POST['keyword']; $category = $_POST['category']; $tag = $_POST['field_name']; $tagimplode = implode(',',$tag); $date = date("d F, Y"); $sql = "INSERT INTO `blog`(`image`, `alt`, `heading`, `blog_content`, `blog_url`, `blog_title`, `blog_description`, `blog_keyword`, `category`, `tag`, `date_creation`) VALUES ('$signatureImageName', '$alt', '$or_heading', '$blog_content_area','$blog_url_area','$blog_title_area','$blog_description_area','$blog_keyword','$category','$tagimplode','$date')"; if(mysqli_query($conn,$sql) == true){ echo '<script>alert("Blog Insert Successfully")</script>'; }else{ echo '<script>alert("Error ! Blog Insert")</script>'; } } ?>