hjkhjkjhkhjkgjghjhgjhgjghjhghjghjhgjjnbvnvbnvk
bnmbnmbnhjkhjkhjkhjktyutyutyuytutyutyutyhgjgjghjgjghjguytutyry
/
home
/
b4h4ej4a6kj6
/
public_html
/
kitsandcleats.in
/
admin
/
Upload FileeE
HOME
<?php include('functions.php'); $obj = new Operations(); if($_GET['mode'] == 'edit'){ $w = "where id = '".$_GET['id']."'"; $getrs = $obj->getSingle('blog',$w); } if($_POST){ $title = $_POST['name']; $title = str_replace(" ", "-", strtolower($title)); $title; function format_uri( $string, $separator = '-' ) { $string=trim($string); $accents_regex = '~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i'; $special_cases = array( '&' => 'and', "'" => ''); $string = mb_strtolower( trim( $string ), 'UTF-8' ); $string = str_replace( array_keys($special_cases), array_values( $special_cases), $string ); $string = preg_replace( $accents_regex, '$1', htmlentities( $string, ENT_QUOTES, 'UTF-8' ) ); $string = preg_replace("/[^a-z0-9]/u", "$separator", $string); $string = preg_replace("/[$separator]+/u", "$separator", $string); return $string; } $bnr_image= $_FILES['image']['name']; move_uploaded_file($_FILES['image']['tmp_name'],'./images/blogs/'.$bnr_image); if(empty($bnr_image)){ $bnr_image=$_POST['old_image']; } $data = array( 'category'=>$_POST['category'], 'name'=>$_POST['name'], 'title'=>$title, 'message'=>$_POST['message'], 'image'=>$bnr_image, 'views_count'=>0 ); if($_GET['mode'] != 'edit'){ $obj->insert('blog',$data); header('location:add-blog.php?mode=success'); }else{ $obj->update('blog',$data,$getrs['id']); header('location:add-blog.php?mode=update'); } } include 'header.php'?> <?php require_once 'sidebar.php'?> <!--== SIDEBAR ENDS ==--> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script> $(document).ready(function(){ var mode = '<?php echo $_GET['mode']; ?>'; if(mode == 'success'){ $('#insert_msg').slideDown(); $('#insert_msg').delay(1500).fadeOut(); } if(mode == 'update'){ $('#update_msg').slideDown(); $('#update_msg').delay(1500).fadeOut(); window.location = 'view-blog.php'; } }); </script> <!-- Main Content --> <div class="main-content"> <section class="section"> <div class="section-body"> <div class="row"> <div class="col-md-12"> <div class="card"> <form method="post" enctype="multipart/form-data"> <div class="card-header"> <h4>Manage Blog</h4> </div> <div class="alert alert-success" style="text-align:center;font-size:25px;display:none;" id="insert_msg">Data Inserted Succesfully</div> <div class="alert alert-success" style="text-align:center;font-size:25px;display:none;" id="update_msg">Data Updated Succesfully</div> <div class="card-body"> <div class="form-group"> <label for="name">Blog Category:</label> <select class="form-control" name="category"> <option>Select Category</option> <?php $sel = $obj->getAll('blog_category'); foreach ($sel as $sels) { ?> <option value="<?php echo $sels['id'] ?>" <?php if($getrs['category'] == $sels['id']){echo "selected";} ?> ><?php echo $sels['name'] ?></option> <?php }?> </select> </div> <div class="form-group"> <label for="name">Name:</label> <input class="form-control" type="text" name="name" autocomplete="off" placeholder="Name" value="<?php echo $getrs['name'] ?>"> </div> <div class="form-group mb-3"> <script src="https://cdn.ckeditor.com/4.6.2/standard-all/ckeditor.js"></script> <textarea name="message" id="content" class="form-control ckeditor"><?php echo $getrs['message'] ?></textarea> <script> CKEDITOR.replace( 'content', { height: 300, filebrowserUploadUrl: "upload.php" }); </script> <div class="form-group"> <label for="name">Image:</label> <input class="form-control" type="file" name="image" autocomplete="off" > <input type="hidden" name="old_image" value="<?php echo $getrs['image'] ?>"> <?php if($_GET['mode'] == 'edit'){ ?> <img src="./images/blogs/<?php echo $getrs['image'] ?>" width="150"> <?php } ?> </div> </div> <div class="card-footer text-right"> <button class="btn btn-primary">Submit</button> </div> </form> </div> </div> </div> </div> </section> </div> <?php require_once 'footer.php'; ?>