Current File : /home/vedfinancials/public_html/superadmin/edit-blog.php
<?php 
include 'cn.php';
session_start();
$sno=$_GET["id"];
$sql = "SELECT * FROM blogs WHERE id='$sno'" ;
$result = $con->query($sql);
$row = $result->fetch_assoc();
$name=$_SESSION['username'];
if(isset($_SESSION['username'])) {



if(isset($_POST['submit']))
{
    date_default_timezone_set('Asia/Kolkata');
$curdate= date('d-m-Y H:i');

 
if($_FILES['file1']['name']==''){
               $f1 = $row['image'];
            }else{
               $f1 = $_FILES['file1']['name'];
               move_uploaded_file($_FILES['file1']['tmp_name'],'blog/'.$f1);
            }

 
if($_FILES['file2']['name']==''){
               $f2 = $row['thumb'];
            }else{
               $f2 = $_FILES['file2']['name'];
               move_uploaded_file($_FILES['file2']['tmp_name'],'thumb/'.$f2);
            }


 $dec= addslashes($_POST['content']);
 $metadecription= addslashes($_POST['metadescription']);
   /* echo $imageName;
     echo $_POST['name'];
     echo $_POST['price'];
     echo $_POST['category'];
     echo $_POST['description'];
     echo $_POST['pid'];die;*/
  
      
 $query1 ="UPDATE `blogs` SET `title`='".$_POST['title']."',`metatitle`='".$_POST['metatitle']."',`metadescription`='".$metadecription."',`category`='".$_POST['category']."',`thumb`='".$f2."',`image`='".$f1."',`description`='".$dec."',`date`='".$curdate."',`user`='".$name."' WHERE id='$sno'";

$result=mysqli_query($con,$query1);
 echo  "<script type='text/javascript'>alert(\"Updated Successfully\")
 location.href='blogs.php';
  </script>";    

}
?>
<!doctype html><html class="fixed dark" data-style-switcher-options="{'backgroundColor': 'dark'}">
	<head>
		<!-- Basic -->
		<meta charset="UTF-8">
		<title>Mether</title>
		
		
		<!-- Mobile Metas -->
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<!-- Web Fonts  -->		<link href="css?family=Poppins:300,400,500,600,700,800|Shadows+Into+Light" rel="stylesheet" type="text/css">
		<!-- Vendor CSS -->
		<link rel="stylesheet" href="vendor/bootstrap/css/bootstrap.css">		<link rel="stylesheet" href="vendor/animate/animate.compat.css">		<link rel="stylesheet" href="vendor/font-awesome/css/all.min.css">		<link rel="stylesheet" href="vendor/boxicons/css/boxicons.min.css">		<link rel="stylesheet" href="vendor/magnific-popup/magnific-popup.css">		<link rel="stylesheet" href="vendor/bootstrap-datepicker/css/bootstrap-datepicker3.css">
		<!-- Specific Page Vendor CSS -->

		<!-- Theme CSS -->
		<link rel="stylesheet" href="css/theme.css">
		<!-- Theme Custom CSS -->
		<link rel="stylesheet" href="css/custom.css">
		<!-- Head Libs -->
		<script src="vendor/modernizr/modernizr.js"></script>
		<script src="master/style-switcher/style.switcher.localstorage.js"></script>
	</head>
	<body>
		<section class="body">
			<!-- start: header -->
				<?php include("header.php"); ?>
			<!-- end: header -->
			<div class="inner-wrapper">
				<!-- start: sidebar -->
					<?php include("leftnav.php"); ?>
				<!-- end: sidebar -->
				<section role="main" class="content-body card-margin">
					<header class="page-header">
						<h2>Edit Blog</h2>
						<div class="right-wrapper text-end">
							<ol class="breadcrumbs">
								<li>
									<a href="index.php">
										<i class="bx bx-home-alt"></i>
									</a>
								</li>
								<li><span>Edit Blog</span></li>
								
							</ol>
							<a class="sidebar-right-toggle" data-open="sidebar-right"><i class="fas fa-chevron-left"></i></a>
						</div>
					</header>
					<!-- start: page -->
					
					<div class="row">
					
						<div class="col-lg-12">
							<section class="card">
								<header class="card-header">
									<div class="card-actions">
										<a href="#" class="card-action card-action-toggle" data-card-toggle=""></a>
										
									</div>
									<h2 class="card-title">Edit Blog</h2>
									
								</header>
								<form action="" method="post" enctype="multipart/form-data">
								<div class="card-body">
									<div class="row form-group pb-3">
										<div class="col-lg-4">
											<div class="form-group">
											<label class="col-form-label" for="formGroupExampleInput">Title</label>
												<input type="text" class="form-control" name="title" placeholder="" required value="<?php echo $row['title']; ?>">
											</div>
										</div>
										
										<div class="col-lg-4">
											<div class="form-group">
											<label class="col-form-label" for="formGroupExampleInput">Image</label>
												<input type="file"  class="form-control" name="file1" id="file1" >
                                     <img src="blog/<?php echo $row['image']; ?>" 
                                       style="width:100px;height:100px;"/>
											</div>
										</div>
										
										
											<div class="col-lg-4">
											<div class="form-group">
											<label class="col-form-label" for="formGroupExampleInput">Thumbnail Image</label>
												<input type="file"  class="form-control" name="file2" id="file2" >
                                     <img src="thumb/<?php echo $row['thumb']; ?>" 
                                       style="width:100px;height:100px;"/>
											</div>
										</div>
										
							<input type="hidden" name="category" value="<?php echo $row['category']; ?>" />
											<div class="col-lg-6">
											<div class="form-group">
												<label class="col-form-label" for="formGroupExampleInput">Meta Title</label>
												<input type="text" class="form-control" name="metatitle" placeholder="" required value="<?php echo $row['metatitle']; ?>">
											</div>
										</div>
										
										
										<div class="col-lg-6">
											<div class="form-group">
												<label class="col-form-label" for="formGroupExampleInput">Meta Keywords</label>
												<input type="text" class="form-control" name="metakeywords" placeholder="" required value="<?php echo $row['metakeywords']; ?>">
											</div>
										</div>
										
										<div class="col-lg-12">
											<div class="form-group">
												<label class="col-form-label" for="formGroupExampleInput">Meta Description</label>
												<textarea class="form-control" name="metadescription" required value="<?php echo $row['metadescription']; ?>">
												   <?php echo $row['metadescription']; ?> </textarea>
											</div>
										</div>
										
										<div class="col-lg-12">
											<div class="form-group">
											<label class="col-form-label" for="formGroupExampleInput">Content</label>
											<textarea id="editor" name="content">
										<?php echo $row['description']; ?>	    
											</textarea>
												<!--<textarea name="content" data-plugin-markdown-editor="" rows="10" placeholder="Place Content Here" value="<?php echo $row['description']; ?>"><?php echo $row['description']; ?></textarea>-->
											</div>
										</div>
										
									</div>
									
								</div>
							<footer class="card-footer text-end">
								    <center>
									<button class="mb-1 mt-1 me-1 btn btn-success" name="submit">Submit</button></center>
								</footer>
								</form>
							</section>
						</div>
					</div>
					
					<!-- end: page -->
				</section>
			</div>
			<?php include("rightnav.php"); ?>
		</section>
		<!-- Vendor -->
		<script src="vendor/jquery/jquery.js"></script>	
		<!-- Theme Base, Components and Settings -->
		
		<!-- Analytics to Track Preview Website -->
				<script src="https://cdn.ckeditor.com/4.16.2/standard/ckeditor.js"></script>
<link rel="stylesheet" href="https://cdn.ckeditor.com/4.16.2/standard/ckeditor.css">
	<script>
	    	$(function(){
	    CKEDITOR.replace('editor', {
            filebrowserUploadUrl: 'upload-file.php',
            filebrowserUploadMethod: 'form'
        });
	})
	</script>
	</body>
</html>
<?php
}
else {
  header("location:login.php");
}
?>