File manager - Edit - /home/custbahd/irungikitchen.com/admin1/edit_image_modal.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: index.php"); } } ?> <?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> <a href="index.php">Home</a> <br/><br/> <form name="form1" method="post" action="" enctype="multipart/form-data"> <table border="0"> <tr> <td>Image</td> <?php if($image != ""): ?> <img src="images/<?php echo $image; ?>" width="100px" height="100px"> <?php else: ?> <img src="images/default.png" width="100px" height="100px"> <?php endif; ?> </tr> <tr> <td><input type="file" name="image"> </td> </tr> <tr> <td><input type="hidden" name="id" value=<?php echo $_GET['id'];?>></td> <td><input type="submit" name="update" value="Update"></td> </tr> </table> </form> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Generation time: 0.5 |
proxy
|
phpinfo
|
Settings