File manager - Edit - /home/custbahd/irungikitchen.com/admin1/search/edit_image/index.php
Back
<?php // including the database connection file include_once("../../table/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 shop SET image='$image' WHERE id=$id"); if (move_uploaded_file($_FILES['image']['tmp_name'], $target)); //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 shop WHERE id=$id"); while($res = mysqli_fetch_array($result)) { $image = $res['image']; } ?> <html> <head> <title>Update Image</title> </head> <body> <div align="center"> <a href="../../"><img src="../../../assets/images/logo/logo/1.1.png" class="page-header text-center" width="25%"></a> <br><br><br><br> <form name="form1" method="post" action="" enctype="multipart/form-data"> <table border="0"> <tr> <?php if($image != ""): ?> <img src="../../images/<?php echo $image; ?>" width="300px" height="300px"> <?php else: ?> <img src="../../images/default.png" width="300px" height="300px"> <?php endif; ?> </tr> <tr> <td><input type="file" name="image"> </td> <td><input type="hidden" name="id" value=<?php echo $_GET['id'];?>></td> <td><input type="submit" name="update" value="Update"></td> </tr> </table> </form> </div> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Generation time: 6.4 |
proxy
|
phpinfo
|
Settings