D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
grandhou
/
www
/
admin
/
Filename :
edit-wedding-album.php
back
Copy
<?php session_start(); include('include/configpage.php'); include('include/pdo.php'); if(strlen($_SESSION['alogin'])==0) { header('location:index.php'); } else{ $albumid=$_GET['albumId']; if(isset($_POST['btn_cancel'])) { header("location:manage-wedding-album.php"); } if(isset($_GET['albumId']) && !empty($_GET['albumId'])) { $id = $_GET['albumId']; $stmt_edit = $DB_con->prepare('SELECT * FROM weddinglist WHERE id =:uid'); $stmt_edit->execute(array(':uid'=>$id)); $edit_row = $stmt_edit->fetch(PDO::FETCH_ASSOC); extract($edit_row); } else { header("Location: manage-wedding-album.php"); } if(isset($_POST['btn_save_updates'])) { $en_heading = htmlspecialchars($_POST['en_heading'], ENT_QUOTES, 'UTF-8'); $heading = htmlspecialchars($_POST['heading'], ENT_QUOTES, 'UTF-8'); $date = $_POST['date']; $imgFile = $_FILES['user_image']['name']; $tmp_dir = $_FILES['user_image']['tmp_name']; $imgSize = $_FILES['user_image']['size']; if($imgFile) { $upload_dir = 'upload/'; // upload directory $imgExt = strtolower(pathinfo($imgFile,PATHINFO_EXTENSION)); // get image extension $valid_extensions = array('jpeg', 'jpg', 'png', 'gif'); // valid extensions $image = rand(1000,1000000).".".$imgExt; if(in_array($imgExt, $valid_extensions)) { if($imgSize < 5000000) { unlink($upload_dir.$edit_row['image']); move_uploaded_file($tmp_dir,$upload_dir.$image); } else { $errMSG = "Sorry, your file is too large it should be less then 5MB"; } } else { $errMSG = "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; } } else { // if no image selected the old image remain as it is. $image = $edit_row['image']; // old image from database } if(!isset($errMSG)) { $stmt = $DB_con->prepare('UPDATE weddinglist SET name=:en_heading, heading=:heading, date=:date, image=:image WHERE id=:uid'); $stmt->bindParam(':en_heading',$en_heading); $stmt->bindParam(':heading',$heading); $stmt->bindParam(':date',$date); $stmt->bindParam(':image',$image); $stmt->bindParam(':uid',$id); if($stmt->execute()){ header("location:edit-wedding-album.php?albumId=".$id); } else{ $errMSG = "Sorry Data Could Not Updated !"; } } } if(isset($_POST['submit'])) { $name=$_POST['name']; $albumId=$_POST['albumId']; $totalfiles = count($_FILES['file']['name']); $prod=$albumId.".".$name; // Looping over all files for($i=0;$i<$totalfiles;$i++){ $filename = $_FILES['file']['name'][$i]; $newfilename=$prod.".".$filename; // Upload files and store in database if(move_uploaded_file($_FILES["file"]["tmp_name"][$i],'upload/'.$newfilename)){ // Image db insert sql $insert = "INSERT into wedding_album(albumlistid,name,file_name,uploaded_on,status) values('".$albumId."','".$name."','".$newfilename."',now(),1)"; if(mysqli_query($dbhandle, $insert)){ $_SESSION['msg']="Successfully Uploaded"; } else{ echo 'Error: '.mysqli_error($dbhandle); $_SESSION['msg']="Error Occured!!"; } }else{ echo 'Error in uploading file - '.$_FILES['file']['name'][$i].'<br/>'; } } } ?> <!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>GRAND HOUSE | Admin</title> <link type="text/css" href="bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="css/bootstrap.min.css" rel="stylesheet"> <link rel="shortcut icon" href="upload/favicon.ico"> <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="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'> <link type="text/css" href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600' rel='stylesheet'> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script> <script> $(document).ready(function () { var mySelect = $('#first-disabled2'); $('#special').on('click', function () { mySelect.find('option:selected').prop('disabled', true); mySelect.selectpicker('refresh'); }); $('#special2').on('click', function () { mySelect.find('option:disabled').prop('disabled', false); mySelect.selectpicker('refresh'); }); $('#basic2').selectpicker({ liveSearch: true, maxOptions: 1 }); }); </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 content</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">Name</label> <div class="controls"> <input type="text" name="en_heading" value="<?php echo $name;?>" class="span8 tip"> </div> </div> <div class="control-group"> <label class="control-label" for="basicinput">Heading</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">Date</label> <div class="controls"> <input type="text" name="date" value="<?php echo $date;?>" class="span8 tip"> </div> </div> <div class="control-group"> <label class="control-label" for="basicinput">Image <br> (950 x 606)</label> <div class="controls"> <img src="upload/<?php echo $image;?>" width="100px" height="100px" alt="No Image"> <input type="file" name="user_image" accept="image/*" /> </div> </div> <br> <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 class="content"> <div class="module"> <div class="module-head"> <h3>Add More Photos to Album</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 } ?> <?php if(isset($_GET['del'])) {?> <div class="alert alert-error"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Oh snap!</strong> <?php echo htmlentities($_SESSION['delmsg']);?><?php echo htmlentities($_SESSION['delmsg']="");?> <?php } ?> <br /> <form class="form-horizontal row-fluid" method="post" action="" name="manage-album" id="manage-album" enctype="multipart/form-data"> <input type="hidden" name="albumId" value="<?php echo $albumid;?>"> <div class="control-group"> <label class="control-label" for="basicinput">Name</label> <div class="controls"> <input type="text" name="name" value="<?php $sql = "select * from weddinglist where id='".$albumid."'"; // Execute query $result = mysqli_query($dbhandle,$sql); // Loop through each records $cnt=1; while($row = mysqli_fetch_array($result)) { echo $row['name']; }?>" class="span8 tip" readonly> </div> </div> <div class="control-group"> <label class="control-label" for="basicinput">Image</label> <div class="controls"> <input type="file" name="file[]" id="file" multiple class="span8 tip" accept="image/*" required> </div> </div> <div class="control-group"> <div class="controls"> <button type="submit" name="submit" class="btn btn-danger">Create</button> </div> </div> </form> </div> </div> <div class="module"> <div class="module-head"> <h3>Manage Album</h3> </div> <div class="module-body table"> <?php if(isset($_GET['del'])) {?> <div class="alert alert-error"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Oh snap!</strong> <?php echo htmlentities($_SESSION['delmsg']);?><?php echo htmlentities($_SESSION['delmsg']="");?> </div> <?php } ?> <br /> <table cellpadding="0" cellspacing="0" border="0" class="datatable-1 table table-bordered table-striped display" width="100%"> <thead> <tr> <th>#</th> <th>Image</th> <th>Action</th> </tr> </thead> <tbody> <?php $sql = "select * from wedding_album where albumlistid='".$albumid."'"; // Execute query $result = mysqli_query($dbhandle,$sql); // Loop through each records $cnt=1; while($row = mysqli_fetch_array($result)) { $id=$row['album_id']; $file=$row['file_name']; $albumlistid=$row['albumlistid']; //$emailid=$row['emailid']; ?> <tr> <td><?php echo $cnt;?></td> <td><img src="upload/<?php echo $file;?>" width="50px" height="50px"></td> <td> <a href="delete-wedding-album.php?Id=<?php echo $id;?>&albumlistId=<?php echo $albumlistid;?>" onClick="return confirm('Are you sure you want to delete?')"><i class="icon-remove-sign"></i></a></td> </td> </tr> <?php $cnt=$cnt+1; } ?> </table> <br><br> <div style="text-align:center"> <form method="POST"> <button type="submit" name="btn_cancel" class="btn btn-info">Back</button> </form> </div> </div> </div> </div><!--/.content--> </div><!--/.span9--> </div> </div><!--/.container--> </div><!--/.wrapper--> <?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> </body> <?php } ?>