korsygfhrfggfhfgfffgffg6655665dtggggggzangaiide
Elehhjhjjkjkfpf6df56fd65ffff
/
home2
/
sunpublicschools
/
public_html
/
SunShine_AdMin
/
Upload FileeE
HOME
<?php include 'header.php'; include 'config.php'; ?> <div class="content-wrapper"> <div class="page-title"> <div> <p><i class="fa fa-eye"></i> Campus </p> </div> </div> <div class="card"> <?php if(isset($_POST['submit'])) { $title = $_POST['title']; $content = mysqli_real_escape_string($connect,$_POST['descp']); $content2 = mysqli_real_escape_string($connect,$_POST['descp2']); $target_dir = "images/campus/"; $fileName = basename($_FILES["image"]["name"]); $tmp = explode(".", $fileName); $fileExtension = strtolower(end($tmp)); $target_file = $target_dir ."MSR".time().".".$fileExtension; move_uploaded_file($_FILES['image']['tmp_name'],$target_file); $cat_qey = "INSERT INTO campus (title,image) VALUES ('$title','$target_file')"; $cat_res = mysqli_query($connect, $cat_qey); if ($cat_res) { ?> <div class="alert msg" role="alert" style="text-align: center;color:green;font-size: 20px;margin-top: 21px;"> Added Successfully </div> <?php } } ?> <form action="" method="post" enctype="multipart/form-data"> <div class="row"> <div class="col-md-6"> <label>Add Name</label> <input type="text" name="title" class="form-control" required> </div> <div class="col-md-4"> <label>Add Image</label> <input type="file" name="image" accept="image/jpg, image/jpeg, image/png" id="imageUpload" onchange="return fileValidation(this)"> </div> </div> <br> <div class="row"> <div class="col-md-4"> <input type="submit" name="submit" class="btn btn-success" value="Submit"> </div> </div> </form> </div> <div class="card"> <div class="row"> <div class="col-md-12"> <p style="font-weight: bold;color: #1ec351;">Campus</p> </div> </div> <div class="row"> <div class="table-responsive"> <table class="table table-bordered table-striped"> <tr> <th >Image</th> <th >Name</th> <th >Edit</th> <th >Delete</th> </tr> <?php $start=0; $limit=15; if(isset($_GET['id'])) { $id=$_GET['id']; $start=($id-1)*$limit; } else { $id=1; $start=($id-1)*$limit; } $query = "SELECT * from campus LIMIT $start,$limit"; $result = mysqli_query($connect,$query); while($row = mysqli_fetch_array($result)) { ?> <tr> <td><img src="<?php echo $row['image']; ?>" height="100" width="100" /> </td> <td><?php echo $row['title'];?></td> <td> <a href="edit_campus.php?id=<?php echo $row['id'];?>"><button data-toggle="tooltip" title="Edit" class="btn btn-green btn-xs"><i class="fa fa-edit"></i></button></a> </td> <td> <a href="delete_campus.php?id=<?php echo $row['id'];?>"><button data-toggle="tooltip" title="Delete" Onclick="return ConfirmDelete()" class="btn btn-danger btn-xs"><i class="fa fa-trash"></i></button></a> </td> </tr> <?php } ?> </table> <?php echo "</ul style='display: inline;'>"; $rows=mysqli_num_rows(mysqli_query($connect,"SELECT * from campus")) ; $total=ceil($rows/$limit); if($id >1) { echo "<a href='?id=".($id-1)."' class='button'> PREVIOUS </a>"; } if($id != $total) { echo "<a href='?id=".($id+1)."' class='button'> NEXT </a>"; } echo "<ul class='page'>"; for($i=1;$i<=$total;$i++) { if($i==$id) { echo "<li class='current'>".$i."</li>"; } else { echo "<li><a href='?id=".$i."'>".$i."</a></li>"; } } echo "</ul>"; ?> </div> </div> </div> </div> <script> function ConfirmDelete() { return confirm("Are you sure you want to delete?"); } </script> <script> function fileValidation(file){ var fileInput = file.value; var allowedExtensions = /(\.jpg|\.jpeg|\.png)$/i; if(!allowedExtensions.exec(fileInput)){ alert('Please upload file having extensions .jpeg/.jpg/.png only.'); file.value = ''; file.focus(); return false; }else{ return true; } } </script> <script src="js/jquery-2.1.4.min.js"></script> <script src="js/bootstrap.min.js"></script> <script src="js/plugins/pace.min.js"></script> <script src="js/main.js"></script> <script src="//cdn.ckeditor.com/4.9.2/standard/ckeditor.js"></script> <script type="text/javascript"> CKEDITOR.replace('descp'); CKEDITOR.replace('descp2'); </script>