D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
shubmkcj
/
designpitara.com
/
dash
/
Filename :
edit-blog.php
back
Copy
<?php session_start(); include 'config.php'; if($_SESSION['design1'] == ''){ echo "<script>location.replace('index.php')</script>"; } $url = base64_decode($_GET['id']); ?> <!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 class="light"> <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>Edit Blog</h6> </div> </div> </div> <div class="card-body"> <?php $sql = "select * from blog where id='$url' order by id desc"; $result = mysqli_query($conn,$sql); while( $row = mysqli_fetch_assoc($result)){ ?> <form action="" method="post" enctype="multipart/form-data"> <div class="form-row mb-3"> <div class="col-md-12 mb-3"> <img src="../image/<?php echo $row['image'] ?>" height="100px"> <input type="hidden" class="form-control" name="old_image" value="<?php echo $row['image'] ?>"> </div> <div class="col-md-12 mb-3"> <label for="validationCustom01">Upload Image</label> <input type="file" class="form-control" name="blog_img"> </div> </div> <div class="form-row mb-3"> <label>Image Alt</label> <input type="text" class="form-control" name="alt" value="<?php echo $row['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" value="<?php echo $row['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;'><?php echo $row['blog_content'] ?></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" value="<?php echo $row['blog_url'] ?>"> </div> <div class="col-md-6"> <label>Blog Title</label> <input class="form-control" name="title" value="<?php echo $row['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" value="<?php echo $row['blog_description'] ?>"> </div> <div class="col-md-6"> <label>Blog keyword</label> <input class="form-control" name="keyword" value="<?php echo $row['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><?php echo $row['category'] ?></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"> <?php $tag = explode(',',$row['tag']); foreach($tag as $c){ if($c == ''){ }else{ ?> <div class="col-md-12 col-lg-12 p-0 mb-3"> <input type="text" name="field_name[]" class="form-control" value="<?php echo $c ?>" > </div> <?php } }?> <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> <?php } ?> </div> </div> </div> </div> </div> </div> <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' ], }); </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); } $old_image = $_POST['old_image']; if($signatureImageName == ''){ $newimage = $old_image; }else{ $newimage = $signatureImageName; } $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); $sql ="UPDATE `blog` SET `image`='$newimage',`alt`='$alt',`heading`='$or_heading',`blog_content`='$blog_content_area',`blog_url`='$blog_url_area',`blog_title`='$blog_title_area',`blog_description`='$blog_description_area',`blog_keyword`='$blog_keyword',`category`='$category',`tag`='$tagimplode' WHERE id='$url'"; if(mysqli_query($conn,$sql) == true){ echo '<script>alert("Blog Insert Successfully")</script>'; echo "<script>location.replace('')</script>"; }else{ echo '<script>alert("Error ! Blog Insert")</script>'; echo "<script>location.replace('')</script>"; } } ?>