File manager - Edit - /home/custbahd/public_html/dbmanager/edit.php
Back
<?php // including the database connection file include_once("config.php"); if(isset($_POST['update'])) { $id = mysqli_real_escape_string($mysqli, $_POST['id']); $name = mysqli_real_escape_string($mysqli, $_POST['name']); $code = mysqli_real_escape_string($mysqli, $_POST['code']); $price = mysqli_real_escape_string($mysqli, $_POST['price']); $description = mysqli_real_escape_string($mysqli, $_POST['description']); $image = mysqli_real_escape_string($mysqli, $_POST['image']); // checking empty fields if(empty($name) || empty($code) || empty($price) || empty($description)) { if(empty($name)) { echo "<font color='red'>Name field is empty.</font><br/>"; } if(empty($code)) { echo "<font color='red'>Code field is empty.</font><br/>"; } if(empty($price)) { echo "<font color='red'>Price field is empty.</font><br/>"; } if(empty($description)) { echo "<font color='red'>Description field is empty.</font><br/>"; } } else { //updating the table $result = mysqli_query($mysqli, "UPDATE hotdogs SET name='$name',code='$code',price='$price',description='$description',image='$image' WHERE id=$id"); //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 hotdogs WHERE id=$id"); while($res = mysqli_fetch_array($result)) { $name = $res['name']; $code = $res['code']; $price = $res['price']; $description = $res['description']; $image = $res['image']; } ?> <html> <head> <title>Edit Products</title> </head> <body> <a href="index.php">Home</a> <br/><br/> <form name="form1" method="post" action="edit.php"> <table border="0"> <tr> <td>Name</td> <td><input type="text" name="name" value="<?php echo $name;?>"></td> </tr> <tr> <td>Code</td> <td><input type="text" name="code" value="<?php echo $code;?>"></td> </tr> <tr> <td>Price</td> <td><input type="text" name="price" value="<?php echo $price;?>"></td> </tr> <tr> <td>Description</td> <td><input type="text" name="description" value="<?php echo $description;?>"></td> </tr> <tr> <td>Image</td> <td><input type="text" name="image" value="<?php echo $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.49 |
proxy
|
phpinfo
|
Settings