File manager - Edit - /home/custbahd/mediagepr.com/admin/testimonials/edit_image/index.php
Back
<?php // including the database connection file include_once("../db/config.php"); if(isset($_POST['update'])) { $id = mysqli_real_escape_string($mysqli, $_POST['id']); $image = mysqli_real_escape_string($mysqli, $_FILES['image']['name']); $target = "../images/".basename($_FILES['image']['name']); // checking empty fields if(empty($image)) { echo "<font>Please click browse below the image to select new image to update or <a href='index.php' class='back'>Go back.</a></font><br/>"; } else { //updating the table $result = mysqli_query($mysqli, "UPDATE testimonials SET image='$image' WHERE id=$id"); if (move_uploaded_file($_FILES['image']['tmp_name'], $target)) { $msg = "Image uploaded successfully"; }else{ $msg = "There was a problem uploading image"; } //redirectig to the display pcode. In our case, it is index.php header("Location: ../"); } } ?> <?php //getting id from url $id = $_GET['id']; //selecting data associated with this particular id $result = mysqli_query($mysqli, "SELECT * FROM testimonials WHERE id=$id"); while($res = mysqli_fetch_array($result)) { $image = $res['image']; } ?> <html> <head> <title>Update Image</title> <style type="text/css"> .edit-img img { width: 20%; border-radius: 100%; box-shadow: 0 0 0 1px red; } input[type=file] { margin-top: 30px; border: none; background: none; } input[type=submit] { color: white; padding: 10px; margin-top: 30px; border: none; border-radius: 5px; background: red; } .back { font-weight: bold; color: red; } a { text-decoration: none; } </style> </head> <body> <br> <br> <div align="center"> <a href="../"> <img src="../../../../assets/img/logo5.png" class="page-header text-center" width="25%"> </div> </a> <br> <br> <br> <div align="center"> <form name="form1" method="post" action="" enctype="multipart/form-data"> <div class="edit-img"> <?php if($image != ""): ?> <img src="../images/<?php echo $image; ?>" width="130%"> <?php else: ?> <img src="../images/default.png" width="30%"> <?php endif; ?> </div> <div><input type="file" name="image"> </div> <div><input type="hidden" name="id" value=<?php echo $_GET['id'];?>></div> <div><input type="submit" name="update" value="Update Image"></div> </form> </div> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Generation time: 1.7 |
proxy
|
phpinfo
|
Settings