File manager - Edit - /home/custbahd/scorisinternationaljunior.com/admin/activities/active/edit_image_modal.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 color='red'>Please select image to update or <a href='index.php'>Go back</a>.</font><br/>"; } else { //updating the table $result = mysqli_query($mysqli, "UPDATE activities 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 activities 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%; } 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: #253b70; } .back { font-weight: bold; color: #253b70; } a { text-decoration: none; } </style> </head> <body> <div align="center"> <a href="index.php"> <img src="../../../images/logo/ico4.png" class="page-header text-center" width="10%"> </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%" style='border-radius: 10px;'> <?php else: ?> <img src="../images/default.png" width="30%" style='border-radius: 10px;'> <?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> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Generation time: 3.81 |
proxy
|
phpinfo
|
Settings