D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
grandhou
/
www
/
admin
/
Filename :
editblog.php
back
Copy
<?php session_start(); if(strlen($_SESSION['alogin'])==0) { header('location:index.php'); } error_reporting( ~E_NOTICE ); // avoid notice include('include/constant.php'); include('include/pdo.php'); if(isset($_POST['edit_id']) && !empty($_POST['edit_id'])) { $id = $_POST['edit_id']; $stmt_edit = $DB_con->prepare('SELECT * FROM blog WHERE id =:uid'); $stmt_edit->execute(array(':uid'=>$id)); $edit_row = $stmt_edit->fetch(PDO::FETCH_ASSOC); extract($edit_row); } else { header("Location: add-blog.php"); } if(isset($_POST['btn_save_updates'])) { $metatitle = htmlspecialchars($_POST['metatitle'], ENT_QUOTES, 'UTF-8'); $metadesc = htmlspecialchars($_POST['metadesc'], ENT_QUOTES, 'UTF-8'); $heading = htmlspecialchars($_POST['heading'], ENT_QUOTES, 'UTF-8'); $subdesc = htmlspecialchars($_POST['subdesc'], ENT_QUOTES, 'UTF-8'); $blogdescription = htmlspecialchars($_POST['blogdescription'], ENT_QUOTES, 'UTF-8'); $permalink = preg_replace('/[^A-Za-z0-9\-]/', '', $_POST['permalink']); $date = $_POST['date']; $imgFile8 = $_FILES['bookimage']['name']; $tmp_dir8 = $_FILES['bookimage']['tmp_name']; $imgSize8 = $_FILES['bookimage']['size']; if($imgFile8) { $upload_dir8 = 'upload/'; // upload directory $imgExt8 = strtolower(pathinfo($imgFile8,PATHINFO_EXTENSION)); // get image extension $valid_extensions8 = array('jpeg', 'jpg', 'png', 'gif'); // valid extensions $bookimage = rand(1000,1000000).".".$imgExt8; if(in_array($imgExt8, $valid_extensions8)) { if($imgSize8 < 5000000) { unlink($upload_dir8.$edit_row['bookimage']); move_uploaded_file($tmp_dir8,$upload_dir8.$bookimage); } else { $errMSG8 = "Sorry, your file is too large it should be less then 5MB"; } } else { $errMSG8 = "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; } } else { // if no image selected the old image remain as it is. $bookimage = $edit_row['bookimage']; // old image from database } if(!isset($errMSG8)) { $stmt = $DB_con->prepare('UPDATE blog SET metatitle=:metatitle, metadesc=:metadesc, heading=:heading, subdesc=:subdesc, blogdescription=:blogdescription, permalink=:permalink, date=:date, bookimage=:bookimage WHERE id=:uid'); $stmt->bindParam(':metatitle',$metatitle); $stmt->bindParam(':metadesc',$metadesc); $stmt->bindParam(':heading',$heading); $stmt->bindParam(':subdesc',$subdesc); $stmt->bindParam(':blogdescription',$blogdescription); $stmt->bindParam(':permalink',$permalink); $stmt->bindParam(':date',$date); $stmt->bindParam(':bookimage',$bookimage); $stmt->bindParam(':uid',$id); if($stmt->execute()){ ?> <script> alert('Successfully updated blog content...'); window.location.href='add-blog.php'; </script> <?php } else{ $errMSG = "Sorry Data Could Not Updated !"; } } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Wedding Photo Sydeny</title> <link rel="shortcut icon" href="upload/favicon.ico"> <link type="text/css" href="bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link type="text/css" href="bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet"> <link type="text/css" href="css/theme.css" rel="stylesheet"> <link type="text/css" href="images/icons/css/font-awesome.css" rel="stylesheet"> <link type="text/css" href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600' rel='stylesheet'> <script src="<?php echo $tiny; ?>" referrerpolicy="origin"></script> <script src="tiny.js" type="text/javascript"></script> <script language="javascript" type="text/javascript"> function getXMLHTTP() { //fuction to return the xml http object var xmlhttp=false; try{ xmlhttp=new XMLHttpRequest(); } catch(e) { try{ xmlhttp= new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e1){ xmlhttp=false; } } } return xmlhttp; } </script> </head> <body oncontextmenu="return false;"> <script> document.onkeydown = function(e) { if(event.keyCode == 123) { return false; } if(e.ctrlKey && e.shiftKey && e.keyCode == 'I'.charCodeAt(0)){ return false; } if(e.ctrlKey && e.shiftKey && e.keyCode == 'J'.charCodeAt(0)){ return false; } if(e.ctrlKey && e.keyCode == 'U'.charCodeAt(0)){ return false; } } </script> <?php include('include/header.php');?> <div class="wrapper"> <div class="container"> <div class="row"> <?php include('include/sidebar.php');?> <div class="span9"> <div class="content"> <div class="module"> <div class="module-head"> <h3>Edit Blog</h3> </div> <div class="module-body"> <?php if(isset($_POST['submit'])) {?> <div class="alert alert-success"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Well done!</strong> <?php echo htmlentities($_SESSION['msg']);?><?php echo htmlentities($_SESSION['msg']="");?> </div> <?php } ?> <br /> <form class="form-horizontal row-fluid" method="post" enctype="multipart/form-data" > <input type="hidden" name="edit_id" value="<?php echo $id;?>"> <div class="control-group"> <label class="control-label" for="basicinput">Meta Title</label> <div class="controls"> <input type="text" name="metatitle" value="<?php echo $metatitle;?>" class="span8 tip"> </div> </div> <div class="control-group"> <label class="control-label" for="basicinput">Meta Description</label> <div class="controls"> <input type="text" name="metadesc" value="<?php echo $metadesc;?>" class="span8 tip"> </div> </div> <div class="control-group"> <label class="control-label" for="basicinput">Perma Link (*Special characters not allowed)</label> <div class="controls"> <input type="text" name="permalink" value="<?php echo $permalink;?>" class="span8 tip"> </div> </div> <div class="control-group"> <label class="control-label" for="basicinput">Blog Title</label> <div class="controls"> <input type="text" name="heading" value="<?php echo $heading;?>" class="span8 tip"> </div> </div> <div class="control-group"> <label class="control-label" for="basicinput">Sub Description</label> <div class="controls"> <input type="text" name="subdesc" value="<?php echo $subdesc;?>"class="span8 tip"> </div> </div> <div class="control-group"> <label class="control-label" for="basicinput">Description</label> <div class="controls"> <textarea name="blogdescription" id="" cols="30" rows="10"><?php echo $blogdescription;?></textarea> <input name="image" type="file" id="upload" class="hidden" onchange=""> </div> </div> <div class="control-group"> <label class="control-label" for="basicinput">Image<br> (600 x 437)</label> <div class="controls"> <img src="upload/<?php echo $bookimage;?>" width="50px" height="50px" alt="No Image"/> <input type="file" name="bookimage" accept="image/*"/> </div> <br> </div> <div class="control-group"> <label class="control-label" for="basicinput">Date</label> <div class="controls"> <input type="text" name="date" value="<?php echo $date;?>" class="span8 tip"> </div> </div> <div class="control-group"> <div class="controls"> <button type="submit" name="btn_save_updates" class="btn">Update</button> </div> </div> </form> </div> </div> </div><!--/.content--> </div><!--/.span9--> </div> </div><!--/.container--> </div><!--/.wrapper--> </div> <?php include('include/footer.php');?> <script src="bootstrap/js/bootstrap.min.js" type="text/javascript"></script> <script> $(document).ready(function() { $('.datatable-1').dataTable(); $('.dataTables_paginate').addClass("btn-group datatable-pagination"); $('.dataTables_paginate > a').wrapInner('<span />'); $('.dataTables_paginate > a:first-child').append('<i class="icon-chevron-left shaded"></i>'); $('.dataTables_paginate > a:last-child').append('<i class="icon-chevron-right shaded"></i>'); } ); </script> <script src="bootstrap/js/script.js" type="text/javascript"></script> </body>