Viewing file: edit_blog.php (5.88 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
session_start();
include('includes/header.php');
$id = $_REQUEST['id'];
$result = $con->query("SELECT * FROM blog WHERE id='".$id."'");
$row = mysqli_fetch_assoc($result);
if(isset($_POST['submit']))
{
$blog_title = $_POST["blog_title"];
$blog_content = $_POST["blog_content"];
$meta_keywords = $_POST["meta_keywords"];
$meta_description = $_POST["meta_description"];
$query="UPDATE blog SET blog_title = '".$blog_title."',blog_content = '".$blog_content."',meta_keywords = '".$meta_keywords."', meta_description = '".$meta_description."' WHERE id = $id";
$result=$con->query($query);
if($_FILES["blog_image"]["name"]!='')
{
$targetDir = "../blog/";
$fileName = basename($_FILES["blog_image"]["name"]);
$targetFilePath = $targetDir . $fileName;
$fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);
$image = $fileName;
$errors= array();
$file_name = $_FILES['blog_image']['name'];
$file_size =$_FILES['blog_image']['size'];
$file_tmp =$_FILES['blog_image']['tmp_name'];
$file_type=$_FILES['blog_image']['type'];
//$file_ext=strtolower(end(explode('.',$_FILES['blog_image']['name'])));
if($file_size > 2097152){
//$errors[]='File size must be excately 2 MB';
echo '<script>alert("File size must be excately 2 MB")</script>';
}
if(move_uploaded_file($_FILES["blog_image"]["tmp_name"], $targetFilePath)){
$query="UPDATE blog SET blog_image = '".$image."' WHERE id = $id";
$result=$con->query($query);
}
}
echo "<script>window.location.href='view_blog.php';</script>";
exit;
}
?>
<?php
// Storing session data
$_SESSION["role"];
if(!isset($_SESSION["role"]))
{
header("location:admin_login.php");
?>
<script type="text/javascript">
window.location.href = "admin_login.php";
</script>
<?php
}
else
{
?>
<div class="page-container">
<div class="left-content">
<div class="mother-grid-inner">
<!--header start here-->
<div class="header-main">
<div class="header-left">
<div class="logo-name"> <a href="admin_index.php">
<h3>SICS ADMIN</h3>
<br>
<h4>Add Blog</h4>
<!--<img id="logo" src="" alt="Logo"/>-->
</a> </div>
<div class="clearfix"> </div>
</div>
<!--notification menu end -->
<div class="profile_details">
<ul>
<li class="dropdown profile_details_drop"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<div class="profile_img"> <span class="prfil-img"><img src="../images/p1.png" alt=""> </span>
<div class="user-name">
<p>Srishti Innovative</p>
<span>Administrator</span> </div>
<i class="fa fa-angle-down lnr"></i> <i class="fa fa-angle-up lnr"></i>
<div class="clearfix"></div>
</div>
</a>
<ul class="dropdown-menu drp-mnu">
<!-- <li> <a href="#"><i class="fa fa-cog"></i> Settings</a> </li>
<li> <a href="#"><i class="fa fa-user"></i> Profile</a> </li> -->
<li> <a href="admin_login.php"><i class="fa fa-sign-out"></i> Logout</a> </li>
</ul>
</li>
</ul>
</div>
<div class="span5">
<div class="row" style="margin-top:150px;margin-left:50px;">
<form method="post" action="" enctype="multipart/form-data">
<div class="txt-field">
<label>Blog Title</label><br>
<input type="text" id="blog_title" name="blog_title" placeholder="Blog Title" value="<?php echo $row['blog_title'];?>" required>
</div>
<br>
<div class="txt-field">
<label>Blog Content</label><br>
<textarea name="blog_content" id="blog_content" rows="10" cols="80"><?php echo $row['blog_content'];?></textarea>
</div>
<br>
<div class="txt-field">
<label>Blog Image</label><br>
<input type="file" id="blog_image" name="blog_image" placeholder="Blog Image" ><?php if($row['blog_image']){ echo '<img src="../blog/'.$row['blog_image'].'" style="width:100px;" />'; }?>
</div>
<br>
<div class="txt-field">
<label>Meta Keywords</label><br>
<input type="text" id="meta_keywords" name="meta_keywords" value="<?php echo $row['meta_keywords'];?>" placeholder="Meta Keywords" required>
</div>
<br>
<div class="txt-field">
<label>Meta Description</label><br>
<textarea placeholder="Meta Description" rows="2" id="meta_description" name="meta_description"><?php echo $row['meta_description'];?></textarea>
</div>
<br>
<input type="submit" class="logins" name="submit" value="Submit">
</form>
</div>
</div>
<div class="clearfix"> </div>
</div>
<div class="clearfix"> </div>
</div>
<!--heder end here-->
<!-- script-for sticky-nav -->
<!-- /script-for sticky-nav -->
<!--inner block start here-->
</div>
<div class="clearfix"> </div>
<!--slider menu-->
<?php include('includes/sidebar.php');?>
<div class="clearfix"> </div>
</div>
<!--slide bar menu end here-->
<?php include('includes/footer.php');?>
<script>
// Replace the <textarea id="editor1"> with a CKEditor 4
// instance, using default configuration.
CKEDITOR.replace( 'blog_content' );
</script>
<?php
}
?>
|